采购产品:获得Api

时间:2019-02-11 15:03:27

标签: java

我正在尝试获取产品信息,但是出了点问题。有人知道到底出了什么问题吗?

String query ="https://www.googleapis.com/androidpublisher/v3/applications/jksldf/purchases/products/kmdsd/tokens/kjls"

  HttpURLConnection connection;
            try {
                connection = (HttpURLConnection) new URL(query).openConnection();
                connection.setRequestMethod("GET");
                connection.setUseCaches(false);
                connection.connect();
                if (HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
                    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String line;
                    StringBuilder stringBuilder = new StringBuilder();
                    while ((line = bufferedReader.readLine()) != null) {
                        stringBuilder.append(line);
                        JSONArray ja = new JSONArray(stringBuilder);
                    }
                }
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }
    }

1 个答案:

答案 0 :(得分:0)

当我将URL粘贴到浏览器中时,我也会收到一条错误消息:

  "code": 401,
  "message": "Login Required"

这意味着您将需要一个acces令牌才能使用其API