我已将 Google Places API 集成到我的 android 应用程序中。 我已经阅读了 api 文档 See Here .
我已激活适用于 Android 的 Google Places Api 并生成了浏览器 key 当我调用 api 时得到响应错误 -
{"error_message" : "This API project is not authorized to use this API.Please ensure that this API is activated in the APIs Console: Learn more: https://code.google.com/apis/console",
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
我也尝试创建 android key 并返回 -
{
"error_message" : "This IP, site or mobile application is not authorized to use this API key.",
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
我不知道我的代码中有什么问题。
感谢任何帮助。提前致谢。
检查 API 控制台 -
最佳答案
我遇到了同样的问题。在我的例子中,问题是我试图通过这个 url 使用简单的 HttpUrlconnection 发送请求:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=62.25227243964484%2C59.12338379770518&radius=500&key=my_key
my_key 是 Google Places API for Android 的 key ,但是当我切换到 Google Places API Web Service 时,它工作正常。似乎要使用适用于 Android 的 Google Places API 的 key ,您应该遵循本指南 https://developers.google.com/places/android/
关于android - Google Places API 总是返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30044562/