REQUEST_DENIED响应Google Places API请求(传感器= true) [英] REQUEST_DENIED in responce of Google Places API Request (sensor=true)

查看:316
本文介绍了REQUEST_DENIED响应Google Places API请求(传感器= true)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Google Places API获取位置周围的地点。



以下是用于搜索地点的URL的代码。

  NSString * URL = [NSString stringWithFormat:@https://maps.googleapis.com/maps/api/place/search/json?location = -33.8670522,151.1957362&安培;半径= 500安培;传感器=真安培;键= 0dp-j3dkCU_YUb97RHcbL5shmRrJ5R2y4bYz1Vw]; 

NSMutableURLRequest * request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:URL]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:4];
[request setValue:@application / jsonforHTTPHeaderField:@accept];
NSObject * id1 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

以下是JSON格式的响应。

  {
html_attributions:[],
results:[],
status:REQUEST_DENIED

在搜索Google Places API时,它表示不正确的传感器参数值是REQUEST_DENIED的一般原因。但是,在我的情况下,我也提供这一点,正确的。



任何想法,我哪里错了?



再次,我使用的APIKey对于在Android,iPhone和BlackBerry上开发的应用程序是很常见的。那有效吗?或者,我是否需要另一个APIKey(特定于我的iPhone应用程序)?所以,另一个问题是,我可以在所有三个平台上使用相同的密钥吗?

我把你的URL取代了我所知道的关键字,并取得了预期的结果。乍一看,我猜测您的密钥复制/粘贴错误,或者您未在API控制台中启用与此密钥关联的项目的Places API。

请注意,每个项目都可以启用不同的服务 - 您必须手动为每个您希望使用的项目启用Places API - 您能否确认它在控制台中启用,密钥是否准确复制?


I am trying to get places around my location, using Google Places API.

Following is the code, for hitting URL for places search.

NSString *URL = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=-33.8670522,151.1957362&radius=500&sensor=true&key=0dp-j3dkCU_YUb97RHcbL5shmRrJ5R2y4bYz1Vw"];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:URL]
                                                           cachePolicy: NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval: 4];
[request setValue:@"application/json" forHTTPHeaderField:@"accept"];
NSObject *id1 = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];

Which gets me the following response, in JSON Format.

{
  "html_attributions" : [],
  "results" : [],
  "status" : "REQUEST_DENIED"
}

On Searching Google Places API, It says, incorrect sensor parameter value is general cause for "REQUEST_DENIED". But, In my case, I am providing that, too, correct.

Any Idea where am I going wrong ??

Again, the APIKey I am using is common for the App to be develope on Android, iPhone and BlackBerry. Is that Valid ? Or, Do I need another APIKey (Specific for my iPhone App)? So, Another question is, Can i use the same key on all three platforms ??

解决方案

I took your URL and substituted a key that I know works, and got the expected results. At first glance I am guessing either your copied/pasted your key incorrectly, or you have not enabled the Places API for the Project this key is associated with in the API Console.

It's important to note that each project can have different services enabled - and you must enable the Places API manually for each project you wish to use it with -- can you confirm it is enabled in the console and the key is copied accurately?

这篇关于REQUEST_DENIED响应Google Places API请求(传感器= true)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆