How do I get a YouTube video thumbnail from the YouTube API?

后端 未结 30 2694
Happy的楠姐
Happy的楠姐 2020-11-21 07:06

If I have a YouTube video URL, is there any way to use PHP and cURL to get the associated thumbnail from the YouTube API?

30条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 07:28

    In YouTube API V3 we can also use these URLs for obtaining thumbnails... They are classified based on their quality.

    https://i1.ytimg.com/vi//default.jpg -   default
    https://i1.ytimg.com/vi//mqdefault.jpg - medium 
    https://i1.ytimg.com/vi//hqdefault.jpg - high
    https://i1.ytimg.com/vi//sddefault.jpg - standard
    

    And for the maximum resolution..

    https://i1.ytimg.com/vi//maxresdefault.jpg
    

    One advantage of these URLs over the URLs in the first answer is that these URLs don't get blocked by firewalls.

提交回复
热议问题