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

后端 未结 30 2736
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:40

    What Asaph said is right. However, not every YouTube video contains all nine thumbnails. Also, the thumbnails' image sizes depends on the video (the numbers below are based on one). There are some thumbnails guaranteed to exist:

    Width | Height | URL
    ------|--------|----
    120   | 90     | https://i.ytimg.com/vi/

    Additionally, the some other thumbnails may or may not exist. Their presence is probably based on whether the video is high-quality.

    Width | Height | URL
    ------|--------|----
    640   | 480    | https://i.ytimg.com/vi/

    You can find JavaScript and PHP scripts to retrieve thumbnails and other YouTube information in:

    • How to get YouTube Video Info with PHP
    • Retrieve YouTube Video Details using JavaScript - JSON & API v2

    You can also use the YouTube Video Information Generator tool to get all the information about a YouTube video by submitting a URL or video id.

提交回复
热议问题