Youtube API - How to limit results for pagination?

zardon picture zardon · Mar 15, 2010 · Viewed 7.1k times · Source

I want to grab a user's uploads (ie: BBC) and limit the output to 10 per page.

Whilst I can use the following URL: http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=1&max-results=10

The above works okay.

I want to use the query method instead:

The Zend Framework docs: http://framework.zend.com/manual/en/zend.gdata.youtube.html

State that I can retrieve videos uploaded by a user, but ideally I want to use the query method to limit the results for a pagination.

The query method is on the Zend framework docs (same page as before under the title 'Searching for videos by metadata') and is similar to this:


$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->setTime('today');
$query->setMaxResults(10);
$videoFeed = $yt->getUserUploads( NULL, $query );

print '<ol>'; foreach($videoFeed as $video): print '<li>' . $video->title . '</li>'; endforeach; print '</ol>';

The problem is I can't do $query->setUser('bbc').

I tried setAuthor but this returns a totally different result.

Ideally, I want to use the query method to grab the results in a paginated fashion.

How do I use the $query method to set my limits for pagination?

Thanks.

Answer

zardon picture zardon · Mar 16, 2010

I've decided just to use the user uploads feed as a way of getting pagination to work. http://gdata.youtube.com/feeds/api/users/bbc/uploads/?start-index=1&max-results=10

If there is a way to use the query/search method to do a similar job would be interesting to explore.