我需要从 youtube 中提取特定 channel 播放列表的名称。我正在使用 AFJSONRequestOperation 进行调用。
我不断收到错误代码“(200-299) 中的预期状态代码,得到 403”。我已经在谷歌注册,我的包标识符是正确的。
这是我的代码(我划掉了我的 api KEY 的最后十个字符):
NSURL *url = [[NSURL alloc] initWithString:@"https://www.googleapis.com/youtube/v3/playlists?part=snippet&channelId=UCHvTZKuI5zQnxmbgSE-CFug&maxResults=50&key=AIzaSyDHU-hMgwLf0a4vZe4pPDxqyxxxxxxxxxx"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
AFJSONRequestOperation *operation = [AFJSONRequestOperation
JSONRequestOperationWithRequest:request
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
NSLog(@"%@,",JSON[0][@"title"]);
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog( @"NSError: %@", error.localizedDescription);
}];
[operation start];
我尝试过的解决方案如下: - 使用浏览器键。 - 重新生成 key 。 - 三重检查包标识符。 - 添加了谷歌云 API 和 youtube 分析以及 youtube 数据 API。
有什么建议吗?
提前致谢, -乔尔
最佳答案
这似乎是一个错误 - 我通过从我注册的应用程序中删除包标识符来修复它。
关于ios - YouTube API v3 错误 : 403 but the API key is configured and Bundle identifier is correct,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20985602/