Youtube API-视频评论页面


Youtube API - Video Comments Pagination

我使用以下PHP代码来获取特定视频的注释:

<?php
    $vid = "G0k3kHtyoqc";
    $feedURL = 'http://gdata.youtube.com/feeds/api/videos/' . $vid;
    $entry = simplexml_load_file($feedURL);
    $gd = $entry->children('http://schemas.google.com/g/2005');
    if($gd->comments->feedLink){ 
        $attrs = $gd->comments->feedLink->attributes();
        $commentsURL = $attrs['href']; 
        $commentsCount = $attrs['countHint']; 
    }
    if($commentsURL && $commentsCount > 0){
      $commentsFeed = simplexml_load_file($commentsURL);    
      echo "<ol>";
      foreach($commentsFeed->entry as $comment){
        echo "<li>";
        echo "<a target='_blank' href='http://www.youtube.com/user/" . $comment->author->name . "'>";
        echo $comment->author->name;
        echo "</a>";
        echo " - " . $comment->content;
        echo "</li>";
      }
      echo "</ol>";
    }
?>

上面代码的问题是它只得到最近的24条注释。我需要一种方法来对所有评论进行分页。

非常感谢你的帮助。

感谢

使用"开始索引"参数。从1开始,根据注释数,将[注释数]添加到起始索引参数。

例如:评论的第一页,每页获得25条评论,使用最大结果=25,起始索引=1第二页评论,每页获得25条评论,使用最大结果=25,开始索引=26

依此类推=)

问候!