YouTube API V3 - Latest video from username

2019-08-09 09:54发布

问题:

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.