YouTube API V3 - Latest video from username

北战南征 提交于 2019-12-24 17:08:33

问题


I am trying to display the thumbnail from the latest video posted to a youtube channel on a website by using JavaScript - I have seen how to do this with v2 of the API but cannot seem to find an example of this using v3. The example requests seem to be done using a set video:

https://developers.google.com/youtube/v3/getting-started

rather than a channel/username.

I have seen the interactive demo but this seems to be v2 only?

http://gdata.youtube.com/demo/index.html

Any pointers in the right direction would be appreciated. Is it a silly idea to do this in v2 instead?


回答1:


You will do this in two steps. First you will need to get that videoId using v3, then you can show it as in the example.

So the first step will be a channels->list call, in response you will get uploads playlist ID. Then you will plug this id into playlistItems->list call to set playlistId filter. If you set maxResults to 1. That will only return the last video's id.



来源:https://stackoverflow.com/questions/18697514/youtube-api-v3-latest-video-from-username

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!