Jump to content

bigbox

New Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About bigbox

  • Rank
    Newbie
  1. Hello I'm not really an expert on the subject and i was wondering if somebody will help me to make this codes work on YouTube API v3? <?php header('Content-Type: text/html; charset=utf-8'); $channel_id=$_GET['id']; $search_word=$_GET['search_word']; $search_word=str_replace(' ','+',$search_word); //echo'<br>$search_word : '.$search_word.'<br>'; $feedUrl='http://gdata.youtube.com/feeds/api/videos?q='.$search_word.'&orderby=published&start-index=1&max-results=20&v=2&alt=json&author='.$channel_id; //echo'<br>$feedUrl : '.$feedUrl.'<br>'; $contents=file_get_contents($feedUrl); //echo'<br>$contents : '.$contents.'<br>'; $data = json_decode($contents,true); //echo'<br>$data : '.$data.'<br>'; $info = $data["feed"]; $entry = $info["entry"]; $nEntry = count($entry); $PLayListVideos=array(); //echo'<br>$nEntry : '.$nEntry.'<br>'; for($i=0;$i<$nEntry;$i++){ $video = array( 'title' => $entry[$i]['title']['$t'], 'description' => $entry[$i]['media$group']['media$description']['$t'], 'published' =>$entry[$i]['published']['$t'], 'duration'=>$entry[$i]['media$group']['yt$duration']['seconds'], 'videoid'=>$entry[$i]['media$group']['yt$videoid']['$t'], 'favoriteCount'=>$entry[$i]['yt$statistics']['favoriteCount'], 'viewCount'=>$entry[$i]['yt$statistics']['viewCount'], 'numDislikes'=>$entry[$i]['yt$rating']['numDislikes'], 'numLikes'=>$entry[$i]['yt$rating']['numLikes'], 'rating'=>$entry[$i]['gd$rating']['average'], 'max'=>$entry[$i]['gd$rating']['max'], 'min'=>$entry[$i]['gd$rating']['min'] , 'numRaters'=>$entry[$i]['gd$rating']['numRaters'] , 'rtsp1'=>$entry[$i]['media$group']['media$content']['1']['url'], 'rtsp2'=>$entry[$i]['media$group']['media$content']['2']['url'], ); array_push($PLayListVideos,$video); } echo json_encode($PLayListVideos); ?> and this one too <?php header('Content-Type: text/html; charset=utf-8'); $feedUrl='https://gdata.youtube.com/feeds/api/users/'.$_GET['id'].'/playlists?v=2&alt=json&start-index=1&max-results=50'; $data = json_decode(file_get_contents($feedUrl),true); $info = $data["feed"]; $entry = $info["entry"]; $nEntry = count($entry); /* echo "Playlist Name: ".$info["title"]['$t'].'<br/>'; echo "Number of Videos (".$nVideo."):<br/>";*/ $MainFeed=array(); for($i=0;$i<$nEntry;$i++){ $thumbId=split('/',$entry[$i]['media$group']['media$thumbnail'][0]['url'] ); $thumbId=$thumbId[4]; $playList=array( 'title' => $entry[$i]['title']['$t'], 'playlistId' => $entry[$i]['yt$playlistId']['$t'], 'published'=>$entry[$i]['published']['$t'], 'thumbId'=>$thumbId, 'videosCount'=>$entry[$i]['yt$countHint']['$t'], 'videos'=>getVideos($entry[$i]['yt$playlistId']['$t']) ); array_push($MainFeed,$playList); //print_r($entry[$i]); /* echo "Name: ".$entry[$i]['title']['$t'].'<br/>'; echo 'http://www.youtube.com/playlist?list='.$entry[$i]['yt$playlistId']['$t'].'&feature=plcp'.'<br/>'; echo '<br>$thumbId : '.$thumbId .'<br>'; echo "playlistId: ".$entry[$i]['yt$playlistId']['$t']."<br />"; echo "published: ".$entry[$i]['published']['$t']."<br />"; */ // break; } echo '{ "feed":'.json_encode($MainFeed).'}'; function getVideos($playListId){ $feedUrl='https://gdata.youtube.com/feeds/api/playlists/'.$playListId.'?v=2&alt=json'; $data = json_decode(file_get_contents($feedUrl),true); $info = $data["feed"]; $entry = $info["entry"]; $nEntry = count($entry); $PLayListVideos=array(); for($i=0;$i<$nEntry;$i++){ $video = array( 'title' => $entry[$i]['title']['$t'], 'description' => $entry[$i]['media$group']['media$description']['$t'], 'published' =>$entry[$i]['published']['$t'], 'duration'=>$entry[$i]['media$group']['yt$duration']['seconds'], 'videoid'=>$entry[$i]['media$group']['yt$videoid']['$t'], 'favoriteCount'=>$entry[$i]['yt$statistics']['favoriteCount'], 'viewCount'=>$entry[$i]['yt$statistics']['viewCount'], 'numDislikes'=>$entry[$i]['yt$rating']['numDislikes'], 'numLikes'=>$entry[$i]['yt$rating']['numLikes'], 'rating'=>$entry[$i]['gd$rating']['average'], 'max'=>$entry[$i]['gd$rating']['max'], 'min'=>$entry[$i]['gd$rating']['min'] , 'numRaters'=>$entry[$i]['gd$rating']['numRaters'] , 'rtsp1'=>$entry[$i]['media$group']['media$content']['1']['url'], 'rtsp2'=>$entry[$i]['media$group']['media$content']['2']['url'], ); array_push($PLayListVideos,$video); /* echo "Name: ".$entry[$i]['title']['$t'].'<br/>'; echo "published: ".$entry[$i]['published']['$t']."<br />"; echo "duration : ".$entry[$i]['media$group']['yt$duration']['seconds'].'<br/>'; echo "videoid : ".$entry[$i]['media$group']['yt$videoid']['$t'].'<br/>'; echo "Image 90 : ".$entry[$i]['media$group']['media$thumbnail'][0]['url'].'<br/>'; echo "Image 180 : ".$entry[$i]['media$group']['media$thumbnail'][1]['url'].'<br/>'; echo "Image 360 : ".$entry[$i]['media$group']['media$thumbnail'][2]['url'].'<br/>'; echo "favoriteCount : ".$entry[$i]['yt$statistics']['favoriteCount'] .'<br/>'; echo "viewCount : ".$entry[$i]['yt$statistics']['viewCount'] .'<br/>'; echo "numDislikes : ".$entry[$i]['yt$rating']['numDislikes'] .'<br/>'; echo "numLikes : ".$entry[$i]['yt$rating']['numLikes'] .'<br/>'; echo "rating : ".$entry[$i]['gd$rating']['average'] .'<br/>'; echo "max : ".$entry[$i]['gd$rating']['max'] .'<br/>'; echo "min : ".$entry[$i]['gd$rating']['min'] .'<br/>'; echo "numRaters : ".$entry[$i]['gd$rating']['numRaters'] .'<br/>'; echo "rtsp1 : ".$entry[$i]['media$group']['media$content']['1']['url'] .'<br/>'; echo "rtsp2 : ".$entry[$i]['media$group']['media$content']['2']['url'] .'<br/>'; */ //print_r($entry[$i]); } return $PLayListVideos; } ?> They are for my android application which stopped working due to the deprecation of YouTube API v2.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.