Created
August 14, 2014 19:50
-
-
Save gabrysiak/18c4095fea852722ebca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Youtube API get thumbnail using Youtube username | |
* @param mixed $client Youtube username | |
* @return mixed Thumbnail src attribute | |
*/ | |
public static function get_yt_thumbnail($client) | |
{ | |
$feed1 = 'https://gdata.youtube.com/feeds/api/users/'.$client.'? fields=media:thumbnail'; | |
// read feed into SimpleXML object | |
$entry2 = simplexml_load_file($feed1); | |
// get nodes in media: namespace for media information | |
$media = $entry2->children('http://search.yahoo.com/mrss/'); | |
$attrs = $media->thumbnail[0]->attributes(); | |
return $thumbnail = $attrs['url']; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment