我正在尝试使用 Google Places API 获取我所在位置周围的位置。
以下是用于点击 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];
这让我得到以下 JSON 格式的响应。
{
"html_attributions" : [],
"results" : [],
"status" : "REQUEST_DENIED"
}
在搜索 Google Places API 时,它说不正确的传感器参数值是“REQUEST_DENIED”的一般原因。但是,就我而言,我提供的也是正确的。
任何想法我哪里错了?
同样,我使用的 APIKey 对于在 Android、iPhone 和 BlackBerry 上开发的应用程序来说很常见。那有效吗?或者,我是否需要另一个 APIKey(特定于我的 iPhone 应用程序)?所以,另一个问题是,我可以在所有三个平台上使用相同的密钥吗?