通读了所有类似的帖子,但找不到解决方案。
NSURL连接:
<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 key 和 iOS 应用程序(包 ID)。
我不确定从这里到哪里去解决这个问题并让它工作。
任何帮助将不胜感激!
最佳答案
仔细检查您的 Google Developers 控制台是否显示为以下屏幕(对于您自己的模块,我的是谷歌地图)。
如果您确定开发人员控制台端的一切都正确,但您仍然看到错误,请从控制台中删除它并创建一个新的,然后重试。是的,这很奇怪,但我之前遇到过类似的问题,我通过删除并重新创建解决了它。
关于ios - Google 自定义搜索 API 返回访问未配置(iOS 应用程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23463449/