Youtube API - Video Comments Pagination

I'm using the following PHP code to get the comments for a specific video:

<?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>";
    }
?>

The problem with the code above is that it only gets the most recent 24 comments. I need a way to paginate through all comments.

Your help is much appreciated.

Thanks

Answers


Use the "start-index" param. Begins on 1, and depending on the comments count, add [comments-count] to start-index param.

For example: First page of comments, getting 25 comments per page, use max-results=25 and start-index=1 Second page of comments, getting 25 comments per page, use max-results=25 and start-index=26

And so on =)

Regards!


Need Your Help

ASP.NET MVC3 upgrade - "Attempt by method [whatever] to access method System.Web.Mvc.Controller.View(...) failed"

c# asp.net-mvc asp.net-mvc-3

I have a unit test that worked fine in MVC2. The test simply defines the Action on the controller, the necessary stubs, and tests the name of the view. However, after upgrading to MVC3, when I invo...

rest api (client side) is working fine on local server but not on online server

php web-services api rest consuming

The following code works fine on local server but on online server throws HTTP ERROR 500. cURL is also enable. Have checked the error log it say;