从youtube的api

时间:2015-09-14 07:39:29

标签: objective-c google-api youtube-api

我在我的移动应用程序中使用youtube api但它无效。 一旦我创建了iOS密钥,我就尝试了它并弹出一个错误:

There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.

然后我读到了它,结果发现我可以通过创建一个没有引用的浏览器密钥来解决它,这样就可以了。

在我这样做之后,我已经尝试过了,并且弹出了这个错误:

"domain": "usageLimits", "reason": "keyExpired", "message": "Bad Request"

我该怎么办?请帮助。

谢谢

编辑:突然而且无处不在,当我在谷歌浏览器上尝试使用网址时,它有效,但在我的应用中,当我使用NSJSONSerialization时,它会返回null结果并显示此错误:

Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Something looked like a 'true' but wasn't around character 0.) {NSDebugDescription=Something looked like a 'true' but wasn't around character 0.}

即使数据不是空的。

1 个答案:

答案 0 :(得分:1)

搞定了:

第一个错误本身就是有效的,我实际上没有改变任何东西。 而另一个错误就是将数据附加在一起,如:

-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
    [_dataResponse appendData:data];
}

并使用dataResponse