Here is a simple PHP snippet helps you to fetch latest 20 videos uploaded on a youtube channel. Replace ‘CHANNEL_ID’ with your youtube channel’s ID. The code will result the Latest 20 video details uploaded on that channel.
1 2 3 4 5 6 7 8 9 10 11 12 |
<?php $feedURL = 'http://gdata.youtube.com/feeds/api/users/CHANNEL_ID/uploads'; $sxml = simplexml_load_file($feedURL); $totvid = $sxml->children('http://a9.com/-/spec/opensearchrss/1.0/')->totalResults; $feedURL = 'http://gdata.youtube.com/feeds/api/users/CHANNEL_ID/uploads?format=5&alt=json&orderby=published&max-result=20&start-index=' . ($totvid-20); $feedop = file_get_contents($feedURL); $obj = json_decode($feedop); for ($i=0; $i<20; $i++) { echo '<b>Title:</b> '.$obj->feed->entry[$i]->title->{'$t'}; echo '<br><a href="http://www.youtube.com/watch?v='.substr($obj->feed->entry[$i]->id->{'$t'},42).'" target="_blank"><img src="'.$obj->feed->entry[$i]->{'media$group'}->{'media$thumbnail'}[0]->url.'"></a><br><br><br>'; } ?> |