我正在尝试访问google Knowledge图形API,但遇到错误com.google.api.client.http.HttpResponseException: 400 Bad Request
"message": "API key not valid. Please pass a valid API key."
,但我没有得到它,我的API密钥是我根据提供的说明获得的正确密钥here < / p>
HttpTransport httpTransport = new NetHttpTransport();
HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
JSONParser parser = new JSONParser();
GenericUrl url = new GenericUrl("https://kgsearch.googleapis.com/v1/entities:search");
url.put("query", "Taylor Swift");
url.put("limit", "10");
url.put("indent", "true");
url.put("key",R.string.API_KEY);
HttpRequest request = requestFactory.buildGetRequest(url);
HttpResponse httpResponse = request.execute();