PHP to feed a video list from a particular channel without Oauth

Youtube API for PHP to feed a video list from a particular channel without Oauth, this API only needs a Channel ID and Channel name. Youtube API is to demonstrate how to show video in our website without 0auth and API Key.

This API is created for only a website to display a video list from their channel without 0auth & API key!

Basic PHP codes are used to feed a video list.

//Enter Your Channel Name
$channel_name="xyz123";
//Enter Your ID
$channel="Uhjfhdkjhfdf454dfde";


// Google Gdata feed url is used to fetch videos from channel.
//
//->results=[2] this is used to how much videos present in feed list         
                $feedURL=urlencode('https://gdata.youtube.com/feeds/api/videos?author=
                '.$channel.'&start-index=1&max-results=2&orderby=published');
                if (@simplexml_load_file($feedURL))
                {
                    $sxml = simplexml_load_file($feedURL);//converts feedlist into XML
                    $counts = $sxml->children('https://a9.com/-/spec/opensearchrss/1.0/');
                    $total = $counts->totalResults;
                    foreach ($sxml->entry as $entry) {
                    $media = $entry->children('https://search.yahoo.com/mrss/');
                    $attrs = $media->group->player->attributes();
                    $watch = $attrs['url']; //URL of the video       
                    $yt = $media->children('https://gdata.youtube.com/schemas/2007');
                    $attrs = $yt->duration->attributes();
                    $length = $attrs['seconds'];  
                    $minute=floor($length/60);
                    $second=$length-$minute*60;        
                    $gd = $entry->children('https://schemas.google.com/g/2005');
                    if ($gd->rating) {
                          $attrs = $gd->rating->attributes();
                          $rating = $attrs['average'];
                    } else {
                          $rating = 0;
                    }
                    $attrs = $media->group->thumbnail[1]
                    ->attributes();//generate thumbnail for each video.
                    
              
...

Actually, it loads the video feed list from Google gdata URL. This simple API is to demonstrate how to show video in our website without 0auth.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.