开发者

Youtube get thumbnail and save at my server

开发者 https://www.devze.com 2023-01-11 21:20 出处:网络
I would like to create a youtube video gallery, and I would like to crop the thumbnail and save it to my server, I tryed with cURL but had no success, it works but it seens that youtube is blocking.

I would like to create a youtube video gallery, and I would like to crop the thumbnail and save it to my server, I tryed with cURL but had no success, it works but it seens that youtube is blocking.

Is there any option to save the youtube thumbnail? http://i3.ytimg.com/vi/BdoQjb6K6XA/0.jpg

I would like to sa开发者_运维百科ve the above thumbnail.

Thanks and best regar´s


You want to use file_get_contents, I believe. Something like below should work:

$image = file_get_contents('http://i3.ytimg.com/vi/BdoQjb6K6XA/0.jpg'); 
$file  = fopen('[path to save file]', 'w+'); 

fputs($file, $image); 
fclose($file); 
unset($image) 

Something like this should work though I didn't test. Also you should add some error handlers to the end of the remote statements so you can know if they failed. Just a quick example.

0

精彩评论

暂无评论...
验证码 换一张
取 消