【发布时间】:2013-07-15 14:25:51
【问题描述】:
我正在为我的 iOS 应用程序使用 Google Places API。我已启用 Google Maps Android API v2,来自 API 控制台的 Places API。在 API 访问部分创建 iOS 密钥。我正在使用以下代码向 Google Places API 发出请求:
NSString *finalString = [NSString stringWithFormat:@"https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&radius=5000&keyword=restaurants&sensor=false&key=PASTE_GENERATED_KEY_HERE",_location.coordinate.latitude,_location.coordinate.longitude];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:finalString]];
但我在 JSON 响应中得到关注
{
"debug_info" = (
);
"html_attributions" = (
);
results = (
);
status = "REQUEST_DENIED";
}
我重新生成了不能正常工作的新密钥。有人可以弄清楚我在这里做错了什么。
【问题讨论】:
-
API控制台中是否启用了具体项目?
-
看看这个。 link
-
另外,如果您想要餐馆,最好使用 types=restaurant 而不是关键字。这两者各有不同。
-
@Stavash 我刚刚在 API 控制台中创建了一个项目,并使用我的项目的包标识符生成了 iOS 密钥。我还需要做些什么吗?我怎么知道特定项目是否已启用。我将不胜感激任何帮助.. 3 小时后我有点卡住了
标签: iphone ios google-maps google-places-api