1024programmer News php – How to get YouTube video thumbnail from YouTubeAPI?

php – How to get YouTube video thumbnail from YouTubeAPI?

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

Solution:

Each YouTube video has four generated images. They have the following format:

https://img.youtube.com/vi//0.jpg
https://img.youtube.com/vi//1.jpg
https://img.youtube.com/vi//2.jpg
https://img.youtube.com /vi//3.jpg

The first in the list is the full size image, the others are thumbnail images. Default The thumbnail image (i.e. one of 1.jpg, 2.jpg, 3.jpg) is:

https://img.youtube.com/vi/ /default.jpg

For a high-quality version of the thumbnail, use a URL similar to this:

https://img.youtube.com/vi//hqdefault.jpg

There is also a medium quality version of the thumbnail, using a URL similar to HQ:

https://img.youtube.com/vi//mqdefault.jpg

For the standard definition version of the thumbnail, use a URL similar to this:

https://img.youtube.com/vi//sddefault.jpg

For the maximum resolution version of the thumbnail, use a URL similar to this:

https://img.youtube.com/vi//maxresdefault.jpg

All the above URLs are also available via HTTP. Also, the slightly shorter hostname i3.ytimg.com replaces the above img.youtube.com.

Alternatively, you can use the YouTube Data API (v3) to get the thumbnail image.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/php-how-to-get-youtube-video-thumbnail-from-youtubeapi/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索