开发者

Youtube get thumbnail and save at my server

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜