[英]REQUEST_DENIED in responce of Google Places API Request (sensor=true)
I am trying to get places around my location, using Google Places API. 我正在尝试使用Google Places API获取我所在位置的地点。
Following is the code, for hitting URL for places search. 以下是用于命名地点搜索的URL的代码。
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. 这得到了以下JSON格式的响应。
{
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
On Searching Google Places API, It says, incorrect sensor parameter value is general cause for "REQUEST_DENIED". 在搜索Google Places API时,它说,不正确的传感器参数值是“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. 同样,我正在使用的APIKey通常用于在Android,iPhone和BlackBerry上开发App。 Is that Valid ?
这有效吗? Or, Do I need another APIKey (Specific for my iPhone App)?
或者,我是否需要另一个APIKey(特定于我的iPhone应用程序)? 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.
乍一看,我猜测您复制/粘贴了错误的密钥,或者您没有在API控制台中为项目启用了该密钥与项目的Places API。
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? 重要的是要注意每个项目可以启用不同的服务 - 并且您必须为要使用它的每个项目手动启用Places API - 您是否可以确认它已在控制台中启用并且密钥是否已准确复制?
This error message can also appear if you are missing required parameters. 如果缺少必需参数,也会出现此错误消息。
For example, I just had a similar issue using the /autocomplete
endpoint of the Places API. 例如,我在使用Places API的
/autocomplete
端点时遇到了类似的问题。
Sending a request to https://maps.googleapis.com/maps/api/place/autocomplete/json?key=XXXXXXXXXXXXXXXXXX&input=San , I was getting a response like this: 发送请求到https://maps.googleapis.com/maps/api/place/autocomplete/json?key=XXXXXXXXXXXXXXXXXX&input=San ,我收到的回复如下:
{
"predictions" : [],
"status" : "REQUEST_DENIED"
}
Even though it looks like a permissions issue (at least to me), it turns out I was simply missing a required sensor
parameter. 即使它看起来像权限问题(至少对我来说),但事实证明我只是缺少一个必需的
sensor
参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.