【发布时间】:2014-05-05 01:11:26
【问题描述】:
阅读所有类似的帖子,但找不到解决方案。
NSURLConnection:
<NSURLConnection: 0x178004020> { request: <NSURLRequest: 0x178003ff0> { URL: https://www.googleapis.com/customsearch/v1?key=[API_KEY_SPECIFIC_TO_IOS_BUNDLE_ID]&cx=[SEARCH_ENGINE_ID_FOR_CUSTOM_SEARCH_ENGINE]&q=[SEARCH_STRING] } }
回复:
{
error = {
code = 403;
errors = (
{
domain = usageLimits;
message = "Access Not Configured. Please use Google Developers Console to activate the API for your project.";
reason = accessNotConfigured;
}
);
message = "Access Not Configured. Please use Google Developers Console to activate the API for your project.";
};
}
我访问了 Google Developers Console,并为我的项目探索了自定义搜索 API。对应这个网址:
https://console.developers.google.com/project/[PROJECT ID]/apiui/api/customsearch/method/search.cse.list
它成功运行并显示了这个请求(连同正确的结果):
GET https://www.googleapis.com/customsearch/v1?q=[SEARCH_STRING]&cx=[SEARCH_ENGINE_ID_FOR_CUSTOM_SEARCH_ENGINE]&key={YOUR_API_KEY}
X-JavaScript-User-Agent: Google APIs Explorer
所以我从这个成功中得出结论:
- [SEARCH_ENGINE_ID_FOR_CUSTOM_SEARCH_ENGINE] 值正确
- [SEARCH_ENGINE_ID_FOR_CUSTOM_SEARCH_ENGINE] 值与我的项目相关联,因为我从我的项目中“探索”了它
我确认自定义搜索 API 确实已开启
我还在该项目下方的 API 访问页面上验证了我正在使用简单 API 访问部分中列出的正确 API 密钥和 iOS 应用程序(捆绑 ID)。
我不确定从这里去哪里解决这个问题并让它正常工作。
任何帮助将不胜感激!
【问题讨论】:
-
这里有一个重要的指南,你需要让它工作stackoverflow.com/a/27039037/656600
标签: ios objective-c google-api google-custom-search