首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google Places API总是返回错误

Google Places API总是返回错误
EN

Stack Overflow用户
提问于 2015-05-05 12:55:36
回答 11查看 18.1K关注 0票数 12

我已经在我的android应用程序中集成了Google Places API。我已经阅读了api文档See Here

我已经激活了Google Places Api for android并生成了浏览器密钥,当我调用api get error in response时-

代码语言:javascript
复制
{"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密钥,它返回-

代码语言:javascript
复制
{
 "error_message" : "This IP, site or mobile application is not authorized to use this API key.",
 "html_attributions" : [],
 "results" : [],
 "status" : "REQUEST_DENIED"
}

我不明白我的代码中有什么问题。

任何帮助都是非常感谢的。提前谢谢。

检查API控制台-

EN

回答 11

Stack Overflow用户

发布于 2015-07-07 00:35:48

我也有同样的问题。在我的例子中,问题是我试图通过这个url使用简单的HttpUrlconnection发送请求:

代码语言:javascript
复制
 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的关键,但当我切换到Google Places API Web Service时,它工作得很好。似乎要使用key for Google Places API for Android,你应该遵循这个指南https://developers.google.com/places/android/

票数 17
EN

Stack Overflow用户

发布于 2015-05-06 06:43:34

看起来您正在使用Places API Web服务,这需要启用"Google Places API Web Service“并提供一个服务器密钥:https://developers.google.com/places/webservice/intro#Authentication

由于您正在构建一个Android应用程序,您可能想要尝试一下我们在3月份刚刚发布的Places API for Android :)文档可以在https://developers.google.com/places/android/上找到

我希望这能帮到你!

票数 9
EN

Stack Overflow用户

发布于 2015-09-14 19:12:03

我通过以下先决条件解决了这个问题:

1)确保您使用的是以下URL

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=YOURSEARCHTEXT&key=YOUR_SERVER_API_KEY.不要使用你的android/IOS API密钥。

2)请确保您在控制台中开启了以下接口。

Google Places API服务(付费服务)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30044562

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档