使用 v3.0 为旧 gdata link 检索 youtube 视频的正确方法是什么?

What is the correct way of retrieving youtube videos with v3.0 for an old gdata link?

我可以使用什么替代方法 url 来为用户检索 YouTube 视频?

https://gdata.youtube.com/feeds/api/users/USERNAME/uploads?&v=2&max-results=10&alt=jsonc

谢谢

在 V3 中,您必须使用频道 ID,而不是使用用户名(因为它是唯一的,但不保证显示名称是唯一的)。如果不知道频道ID,可以这样获取:

https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={用户名}&key={YOUR_API_KEY}

(别忘了在 console.developers.google.com 注册一个 api 密钥!)

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

https://www.googleapis.com/youtube/v3/search?order=viewCount&part=snippet&channelId={此处为频道 ID}&maxResults=25&key={YOUR_API_KEY}

这将按受欢迎程度对上传的视频进行排序。如果您愿意,可以执行 order=date 以按时间顺序而不是按受欢迎程度对它们进行排序。

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