gpt4 book ai didi

android - Youtube API使用 channel ID提取在 channel 中上传的所有视频

转载 作者:行者123 更新时间:2023-12-03 06:20:12 25 4
gpt4 key购买 nike

我已经创建了一个测试youtube帐户。我想检索使用该 channel ID在此 channel 中上传的所有视频,并在未经身份验证的情况下向用户显示所有这些视频。在下面的YouTube API页面中:

https://developers.google.com/youtube/v3/sample_requests#playlists

我找到了一个API,该API可用于未经请求的请求,以使用 channel ID和API KEY提取所有上传的视频。
You can request information about information about a channel's public playlists without authentication. When you submit an unauthenticated request, you need to include the key argument that specifies the unique API key for the application making the request. For example, this request retrieves the playlists associated with the GoogleDevelopers channel.

GET {base_URL}/playlists?part=snippet
&channelId=UC_x5XG1OV2P6uZZ5FSM9Ttw
&key={YOUR_API_KEY}

其中base_URL是: https://www.googleapis.com/youtube/v3
这给了我 Developers console的响应。但是当我触发 Http request时,它抛出以下错误:
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "keyInvalid",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}

怎么了为什么我在开发人员控制台中没有身份验证就得到响应,为什么在发出直接HTTP请求时抛出错误?

问题解决了:
I was using OAuth key instead of API key. I created server key and used this key to send HTTP request and now getting the Json response.

最佳答案

您可以使用webview将youtube嵌入Fragment中。我已经在WebView的帮助下实现了这一目标,而且我已经在Github上上传了源代码

https://github.com/hiteshsahu/Android-Universal-Web-Content-Loader/blob/master/src/com/serveroverload/universal_webloader/HomeActivity.java

您只需1行就可以在您的应用上显示任何 channel

getSupportFragmentManager().beginTransaction()
.add(R.id.frag_root, UniversalWebViewFragment.newInstance(YOU_TUBE_DEMO_URL, false)).commit();

其中YOU_TUBE_DEMO_URL将重定向到AndroidDevelopers官方 channel 。

另外,您不需要任何身份验证或外部jar。

关于android - Youtube API使用 channel ID提取在 channel 中上传的所有视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36616962/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com