即時得到上試圖使用從谷歌API地圖的網絡服務出現以下錯誤:錯誤使用googmaps API
{ 「ERROR_MESSAGE」:「請給這個API必須通過SSL」, 「結果「:[], 」狀態「: 」REQUEST_DENIED「 }
用於調用網絡服務的網址:
方法用於撥打網絡服務:
enter code here
public static String httpPost(String urlStr) throws Exception {
String novaUrl = urlStr.trim();
novaUrl = urlStr.replaceAll(" ", "+");
novaUrl = novaUrl.replaceAll("\r", "");
novaUrl = novaUrl.replaceAll("\t", "");
novaUrl = novaUrl.replaceAll("\n", "");
URL url = new URL(novaUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setUseCaches(false);
conn.setAllowUserInteraction(false);
conn.setRequestProperty("Content-Type", "application/x-www-form-urldecoded");
// Create the form content
OutputStream out = conn.getOutputStream();
Writer writer = new OutputStreamWriter(out, "UTF-8");
writer.close();
out.close();
// Buffer the result into a string
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
conn.disconnect();
Spanned retorno = Html.fromHtml(sb.toString());
return retorno.toString();
}
如何解決此問題?
謝謝。
現在而言,我收到此錯誤:{ 「ERROR_MESSAGE」: 「此網站或IP沒有被授權使用該API密鑰」, 「結果」: [], 「status」:「REQUEST_DENIED」 } – user2952653
如提及請交叉檢查您正在使用的API密鑰..請張貼您的清單文件。 – AndroidHacker