Php Youtube API-视频评论分页

Php Youtube API-视频评论分页,php,api,youtube,pagination,Php,Api,Youtube,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->

我使用以下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>";
    }
?>
children('http://schemas.google.com/g/2005');
如果($gd->comments->feedLink){
$attrs=$gd->comments->feedLink->attributes();
$commentsURL=$attrs['href'];
$CommentScont=$attrs['countHint'];
}
如果($commentsURL&&$CommentScont>0){
$commentsFeed=simplexml\u加载\u文件($commentsURL);
回声“;
foreach($commentsFeed->entry as$comment){
回声“
  • ”; 回声“; 回显“-”$comment->content; 回声“
  • ”; } 回声“; } ?>
    上面代码的问题是它只得到最近的24条注释。我需要一种方法来整理所有的评论

    非常感谢你的帮助

    谢谢使用“开始索引”参数。从1开始,根据注释计数,添加[comments count]以开始索引参数

    例如: 评论的第一页,每页25条评论,使用max results=25,start index=1 第二页评论,每页25条评论,使用max results=25,start index=26

    等等=)

    问候