我正在尝试使用Google API地理编码服务,如下所示:
https://maps.googleapis.com/maps/api/geocode/json?&address=melbourne&key=xxx&sensor=false
我得到的回应总是:
{
"results" : [],
"status" : "REQUEST_DENIED"
}
我启用了Google Maps API v3和Places API服务。我甚至设置了账单。我尝试删除并重新创建了许多键 - 所有键都具有相同的效果。我已尝试过来自不同网络的服务,也有相同的结果。
在Google API信息中心的报告部分中,我可以看到请求累积的数量,但响应始终为Request_Denied
。
有人可以帮忙吗?
答案 0 :(得分:22)
在以下情况下,Places API会返回“status”:“REQUEST_DENIED”:
You have not activated the Places API Service in the services tab of the APIs console.
The key parameter is missing from your request.
The key parameter does not match the your API key in the API Access tab of the APIs console.
Your API key has not been correctly set up in the API Access tab of the APIs Console:
If you are using a Browser key, check that your allowed Referer(s) are correct.
If you are using a Server key, check that your allowed IP(s) are correct.
Android and iOS keys are not supported, please use a Browser or Server key.
The request was not sent as an HTTPS request, HTTPS is required for all Web Service requests.
The incorrect HTTP method was used to send the request:
All requests must be sent as a GET request except for Place Actions.
All Place Actions must be sent as a POST request.
https://developers.google.com/places/faq#why_do_i_keep_receiving_status_request_denied
我没有列出生产服务器的IP地址。
答案 1 :(得分:0)
似乎有意的是,密钥不适用于简单的HTTP查询进行地理编码。谷歌正在阻止任何可能的数据重新利用。请参阅"Usage Limits":
“地理编码API只能与Google地图结合使用; 禁止在地图上显示地理编码结果。“
您可以使用Javascript API在地图上加载结果,如here所述。
答案 2 :(得分:0)
仅像这样更改googleapis来源
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>