首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Zend Gdata库

Zend Gdata库
EN

Stack Overflow用户
提问于 2011-01-06 19:15:04
回答 2查看 1.2K关注 0票数 0

您好,我正在使用zend Gdata Library for youtube视频,我正在尝试显示20多个视频,或者我可以设置要显示的视频数量,但我找不到任何选项

代码语言:javascript
复制
  $yt = new Zend_Gdata_YouTube();
  $videoFeed = $yt->getUserFavorites('liz');

有没有办法获得超过20个或更少的视频Zend Gdata默认值是20

您可以在此处查看

http://framework.zend.com/manual/en/zend.gdata.youtube.html

EN

回答 2

Stack Overflow用户

发布于 2011-01-11 04:50:11

经过进一步的研究,我想我找到了一些解决方案。查看那里的http://code.google.com/apis/youtube/2.0/developers_guide_php.html#Pagination,你应该通过视频源页面编写递归函数循环。对于我的应用程序,它是这样的(类中的方法):

代码语言:javascript
复制
<?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);
 }
票数 2
EN

Stack Overflow用户

发布于 2011-01-07 00:50:45

我不确定在请求用户收藏时是否可以这样做,因为我从未使用过该功能,但当通过搜索词请求视频时,您可以通过setMaxResults方法设置结果编号。您可以使用您的用户收藏夹请求来处理此问题。

下面是我们使用的代码片段:

代码语言:javascript
复制
    $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));
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4614300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档