在youtube api v3(Android)中使用视频ID获取视频标题

时间:2016-06-29 10:05:56

标签: android video youtube

我正在尝试使用youtube api v3中的视频ID获取youtube视频详细信息。使用此网址:

https://www.googleapis.com/youtube/v3/videos?id=7lCDEYXw3mM&key=AIzaSyCA-EL5sT5LCQnYauNMm2Ku_PukvBcz6ms%20&part=snippet,contentDetails

我得到了回复:

{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions.",
"extendedHelp": "https://console.developers.google.com/apis/credentials?project=861763996907"
}
],
"code": 403,
"message": "The Android package name and signing-certificate fingerprint, null and null, do not match the app restrictions configured on your API key. Please use the API Console to update your key restrictions."
}
}

api密钥是我在谷歌开发者控制台中使用我的SHA1代码注册应用程序后获得的密钥。如何克服这个错误?

2 个答案:

答案 0 :(得分:3)

您可以通过移动设备使用GET方法提供服务。您需要做的是创建服务器密钥并使用网址附加此密钥和视频ID并获取数据

例如:如果您使用Volley进行HTTP请求,那么在JsonOBjectRequest url参数中应该看起来像这样:

"https://www.googleapis.com/youtube/v3/videos?id=F4HuIqwGuBU&key=YOUR_SERVER_KEY&fields=items(id,snippet(description,channelId,title,categoryId),statistics)&part=snippet,statistics"

希望这会有所帮助。

答案 1 :(得分:0)

enter image description here

这是因为您没有从控制台密钥中清除安全限制而发生的事情。 试试这些步骤

第1步: - 转到您的项目&点击凭证.. (https://console.developers.google.com/apis/credentials/key/216?project=

步骤2:-Generate API密钥并单击API密钥

步骤3: - 点击无限制并享受..