Orb*_*sii 6 search-engine google-api ios google-custom-search
谷歌自定义搜索从我的iPhone 7.1应用程序返回此403错误.这是在模拟器中运行时的响应:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "accessNotConfigured",
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
],
"code": 403,
"message": "Access Not Configured. Please use Google Developers Console to activate the API for your project."
}
}
Run Code Online (Sandbox Code Playgroud)
下面的步骤有缺陷吗?我想建立一个针对iOS应用程序的工作CSE设置过程.每一步的屏幕截图都有望帮助而不是混淆!
通过https://www.google.com/cse/创建自定义搜索引擎(CSE)
从设置 - >基础知识,获取搜索引擎ID.
通过https://developers.google.com/apis-explorer/#p/customsearch/v1/search.cse.list测试CSE
要获得ID和计费目的的密钥,请通过以下网址创建新项目:https://console.developers.google.com/
在API&auth - > API - >启用"自定义搜索API".没有启用其他API.
在API&auth - >凭据 - >创建新的iOS密钥.
注意:我还尝试了浏览器密钥,搜索结果返回"错误400:无效值".我回到iOS键,因为我在iOS上,错误似乎不那么严重.
从Xcode添加此密钥标识符.
在Xcode中,在步骤3中向URL发出GET请求.使用步骤6-7中的凭据替换{YOUR_API_KEY}.
NSData*响应包含上面显示的错误403.感谢您对错误的看法!
它缺少标题字段X-Ios-Bundle-Identifier.
NSString *bundleID = @"com.yourCompany.yourApp";
//...define request as above
[request setHTTPMethod:@"GET"];
[request setValue:bundleID forHTTPHeaderField:@"X-Ios-Bundle-Identifier"];
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5802 次 |
最近记录: |