您好,我正在使用zend Gdata Library for youtube视频,我正在尝试显示20多个视频,或者我可以设置要显示的视频数量,但我找不到任何选项
$yt = new Zend_Gdata_YouTube();
$videoFeed = $yt->getUserFavorites('liz');有没有办法获得超过20个或更少的视频Zend Gdata默认值是20
您可以在此处查看
http://framework.zend.com/manual/en/zend.gdata.youtube.html
发布于 2011-01-11 04:50:11
经过进一步的研究,我想我找到了一些解决方案。查看那里的http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Pagination,你应该通过视频源页面编写递归函数循环。对于我的应用程序,它是这样的(类中的方法):
<?php
//...
protected function build_favs_html($videos) {
//just saving html here. Mind the .= operator.
// I think you'll be doing this in some other way
$this->_html_response .= View::factory('videos')
->set('videos', $videos)
->set('type', 'load_favs');
// See whether we have another set of results
try {
$videos = $videos->getNextFeed();
}
catch (Zend_Gdata_App_Exception $e) {
//break function execution if there are no more result sets
return null;
}
//if there are result sets we continue calling same function on and on
$this->build_favs_html($videos);
}发布于 2011-01-07 00:50:45
我不确定在请求用户收藏时是否可以这样做,因为我从未使用过该功能,但当通过搜索词请求视频时,您可以通过setMaxResults方法设置结果编号。您可以使用您的用户收藏夹请求来处理此问题。
下面是我们使用的代码片段:
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy('viewCount');
$query->setSafeSearch('strict');
$query->setFormat($searchFormat);
$query->setVideoQuery($searchTerms);
$query->setMaxResults($limit); // number of returned results set here
$query->setStartIndex($offset);
$results = $yt->getVideoFeed($query->getQueryUrl(2));https://stackoverflow.com/questions/4614300
复制相似问题