php - Replacement for gdata -


i have url this, contained in php file find stats video.

how should doing these since gdata no longer works? couldn't find in api! ('http://gdata.youtube.com/schemas/2007'); // node viewer statistics http://gdata.youtube.com/feeds/api/videos/?q= im not quite sure do

-old code- issue lies. need figure out how written new api,

$media = $entry->children('http://search.yahoo.com/mrss/'); // nodes in media: namespace media information

$attrs = $media->group->player->attributes();              // video player url $watch = $attrs['url'];   $attrs = $media->group->thumbnail[0]->attributes();        // video thumbnail $thumbnail = $attrs['url'];  $yt = $media->children('http://gdata.youtube.com/schemas/2007');   // <yt:duration> node video length $attrs = $yt->duration->attributes(); $length = $attrs['seconds'];   $yt = $entry->children('http://gdata.youtube.com/schemas/2007');   // <yt:stats> node viewer statistics $attrs = $yt->statistics->attributes(); $viewcount = $attrs['viewcount'];   $gd = $entry->children('http://schemas.google.com/g/2005');        // <gd:rating> node video ratings if ($gd->rating) {     $attrs = $gd->rating->attributes();     $rating = $attrs['average']; }else{$rating = 0;}  $vid = preg_replace ('/&feature=youtube_gdata_player/','',$watch); // video id $vid = substr($vid, -11); 

-old code new api format 1 part-

<?php error_reporting(0); if ($_cookie['autoexp'] == 'on'){$autoexp = "showresult";}else{$autoexp = "hideresult";} $query = $_post['terms']; $searchnum = $_cookie['snum']; $searchurl = "https://www.googleapis.com/youtube/v3/search?q=".$query."&part=snippet&key=myapikeyishere&max-results=50&format=5";  $feedurl = $searchurl;                             // set feed url $sxml = simplexml_load_file($feedurl);                     // read feed simplexml object  $i = 0; $i++; $sn = 1;  if (empty($query)){     print '<tr><td><div style="margin:auto;padding-top:155px;width:300px;height:120px;text-align:center;"><img src="images/logo.png" height="100"></div></td></tr>'; }  foreach ($sxml->entry $entry) {                     // iterate on entries in feed if ($sn <= $searchnum){      $media = $entry->children('http://search.yahoo.com/mrss/');    // nodes in media: namespace media information      $attrs = $media->group->player->attributes();              // video player url     $watch = $attrs['url'];       $attrs = $media->group->thumbnail[0]->attributes();        // video thumbnail     $thumbnail = $attrs['url'];      $yt = $media->children('http://gdata.youtube.com/schemas/2007');   // <yt:duration> node video length     $attrs = $yt->duration->attributes();     $length = $attrs['seconds'];       $yt = $entry->children('http://gdata.youtube.com/schemas/2007');   // <yt:stats> node viewer statistics     $attrs = $yt->statistics->attributes();     $viewcount = $attrs['viewcount'];       $gd = $entry->children('http://schemas.google.com/g/2005');        // <gd:rating> node video ratings     if ($gd->rating) {         $attrs = $gd->rating->attributes();         $rating = $attrs['average'];     }else{$rating = 0;}      $vid = preg_replace ('/&feature=youtube_gdata_player/','',$watch); // video id     $vid = substr($vid, -11);      if ($length <= 600){         $i++;         print " <tr class=\"d".($i & 1)."\"><td>";         ?>      <table class="searchresults">     <tr><td>         <b>- <a href="#!" onclick="showinfo('<?=$vid?>')"><?php echo $media->group->title; ?></a></b>     </td><td width="110">         <div style="padding-left:7px;"><b>length : &nbsp;</b> <?=substr(gmdate("i:s", '00'.$length),1)?></div>     </td><td width="130" align="center">         <a href="#!" onclick="getit('<?=$vid?>');"><img src="images/mp3.png" onmouseover="this.src='images/mp32.png';" onmouseout="this.src='images/mp3.png';" title="get mp3"></a>     </td></tr>     </table>     <div id="infodiv-<?=$vid?>" class="<?=$autoexp?>">         <table class="searchresults" style="height:25px;" >         <tr><td>             <div class="menubar2" style="position:relative;top:-5px;">                 <div style="float:left;padding-left:10px;position:absolute;margin-top:-1px;z-index:5;"><img src="<?=$thumbnail?>" height="42" border="1"></div>                 <div style="float:left;text-align:left;padding-left:85px;color:#333333;"><b>author:</b> <?php echo $entry->author->name; ?><div style="color:#000000;padding-top:4px;padding-bottom:0px"><small><?=$viewcount?> views</small></div></div>                 <div style="float:right;margin-right:20px;margin-top:9px;border-style:solid;border-width:1px;"><object width= "217" height="30"><param name="movie" value="http://www.youtube.com/v/<?=$vid?>&rel=0&fs=0&theme=light&showinfo=0&modestbranding=1&autohide=0&color=red"></param><param name="allowfullscreen" value="false"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/<?=$vid?>&rel=0&fs=0&theme=light&showinfo=0&modestbranding=1&autohide=0&color=red" type="application/x-shockwave-flash" allowfullscreen="false" width="217" height="30" allowscriptaccess="always"></embed></object></div>              </div>         </td></tr>         </table>     </div>     </td></tr>     <?php      $sn++;     }else{}  }else{} } ?> </table> 

how go making work again?

for video statistics can request

get https://www.googleapis.com/youtube/v3/videos?part=statistics&id={video_id}&key={your_api_key} 

for more info kind of data can video, read this.

you can try endpoint using this.


Comments