适用于YouTube 2.0 API播放列表的3.0版替代方案

时间:2015-04-26 16:38:32

标签: youtube-api

我们确实有这个播放列表。这很棒,因为使用此信息我们可以在YouTube上显示最新视频。

https://gdata.youtube.com/feeds/base/users/africawoodgrow/uploads?alt=rss&v=2&orderby=published

我们如何从新的3.0 API收到相同的信息?

1 个答案:

答案 0 :(得分:4)

您需要做的第一件事就是注册API密钥 - 您可以通过在console.developers.google.com上创建项目,将YouTube数据API设置为"来执行此操作"并创建一个公共访问密钥。

获得API密钥后,您需要获取您感兴趣的渠道ID(而不是用户名)。如果您不知道频道ID,可以这样理解:

https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername= {用户名}&安培;关键= {} YOUR_API_KEY

获得频道ID后,您可以使用搜索端点获取这些视频,如下所示:

https://www.googleapis.com/youtube/v3/search?order=date&part=snippet&channelId= {channel id here}& maxResults = 25& key = {YOUR_API_KEY}

您还可以使用许多其他参数来检索视频;有关详细信息,请参阅https://developers.google.com/youtube/v3/docs/search/list