Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Youtube api 从YouTube频道的条目中获取喜欢/不喜欢计数';s上传提要_Youtube Api - Fatal编程技术网

Youtube api 从YouTube频道的条目中获取喜欢/不喜欢计数';s上传提要

Youtube api 从YouTube频道的条目中获取喜欢/不喜欢计数';s上传提要,youtube-api,Youtube Api,我正在尝试检索频道提要中喜欢和不喜欢的内容。但只得到了每个视频的评级。有没有办法从喜欢和不喜欢的人那里得到这些信息 我的代码: // set feed URL $feedURL = "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads"; // read feed into SimpleXML object $sxml = simplexml_load_file($feedURL); // get <gd:

我正在尝试检索频道提要中喜欢和不喜欢的内容。但只得到了每个视频的评级。有没有办法从喜欢和不喜欢的人那里得到这些信息

我的代码:

// set feed URL
$feedURL = "http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads";

// read feed into SimpleXML object
$sxml = simplexml_load_file($feedURL);

// get <gd:rating> node for video ratings
$gd = $entry->children('http://schemas.google.com/g/2005');

foreach ($sxml->entry as $entry) {

      if ($gd->rating) {
        $attrs = $gd->rating->attributes();        
        $rating = $attrs['average'];                
      }

      /*
       * does not work
       *
        $yt = $entry->children('http://gdata.youtube.com/schemas/2007');
        $attrs = $yt->rating->attributes();
        $dislikes = $attrs['numDislikes'];
        $likes = $attrs['numLikes'];
      */

}
//设置提要URL
$feedURL=”http://gdata.youtube.com/feeds/api/users/GoogleDevelopers/uploads";
//将提要读入SimpleXML对象
$sxml=simplexml\u加载文件($feedURL);
//获取用于视频分级的节点
$gd=$entry->children($gd)http://schemas.google.com/g/2005');
foreach($sxml->entry as$entry){
如果($gd->评级){
$attrs=$gd->rating->attributes();
$rating=$attrs['average'];
}
/*
*不起作用
*
$yt=$entry->子项('http://gdata.youtube.com/schemas/2007');
$attrs=$yt->rating->attributes();
$dislikes=$attrs['numDislikes'];
$likes=$attrs['numLikes'];
*/
}

有人能帮我吗?

您需要包含
v=2
参数,以指定您需要支持喜欢/不喜欢的数据API的v2

此外,如果您添加
alt=jsonc
,您可能会发现事情会变得更简单,因为这样您就可以使用JSON而不是XML。例如