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?
// Get image form video URL
$url = $video['video_url'];
$urls = parse_url($url);
//Expect the URL to be http://youtu.be/abcd, where abcd is the video ID
if ($urls['host'] == 'youtu.be') :
$imgPath = ltrim($urls['path'],'/');
//Expect the URL to be http://www.youtube.com/embed/abcd
elseif (strpos($urls['path'],'embed') == 1) :
$imgPath = end(explode('/',$urls['path']));
//Expect the URL to be abcd only
elseif (strpos($url,'/') === false):
$imgPath = $url;
//Expect the URL to be http://www.youtube.com/watch?v=abcd
else :
parse_str($urls['query']);
$imgPath = $v;
endif;