Paging is not working in Zend Gdata YouTube API

814 views Asked by At

I am working on uploads videos on YouTube using Zend Gdata YouTube API. It uploads well. I can easily fetch the videos on a page. But in this paging doesn't works. i am showing video records on the basis of a specific user records. It shows all records on one page. we have next and back links here. but on click they shows same records on each page.

I have used this: http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=1&max-results=10 But it shows only 10 results. Although I have uploaded more than 12 videos.

I have also used:

$youTubeService = new Zend_Gdata_YouTube();
$query = $youTubeService->newVideoQuery();
$query->setQuery($searchTerm);
$query->setStartIndex($startIndex);
$query->setMaxResults($maxResults);
$feed = $youTubeService->getUserUploads(NULL,$query);

Here $startIndex gives the updated searchindex value for each click on next or previous. But it also giving me only 10 results. Whether $maxResults have any value 3, 4 or 5.

here i want to apply pagination to access 5 videos first. then on click of net link next five results should display.

Please help if anyone have some idea about this.

1

There are 1 answers

1
RockyFord On

It looks like you're going to handle you own pagination.
this query:

http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=1&max-results=10

will show the first 10 results, you'll have change the query for the next results:

http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=11&max-results=10

Try this, you were mixing things up. You were building a search uri and then trying to call it on a specific user. Might work if you did it a different way, this should get you to a starting place.

 $youTubeService = new Zend_Gdata_YouTube(); 
        $query = $youTubeService->newVideoQuery(); 
        $query->author = $author; //if you want a users uploaded videos
        $query->startIndex = $startIndex; 
        $query->maxResults = $maxResults; 
        $feed = $youTubeService->getVideoFeed($query);

you are still going to have to handle pagination yourself, although you can probably find a way to feed this into Zend_Paginator and make it work.