0

こんにちは、私は YouTube ビデオに zend Gdata Library を使用しています。20 以上のビデオを表示しようとしています。または、表示するビデオの数を設定できますが、オプションが見つかりませんでした。

  $yt = new Zend_Gdata_YouTube();
  $videoFeed = $yt->getUserFavorites('liz');

20 以下のビデオを取得する方法はありますか Zend Gdata のデフォルトは 20 です

ここで見ることができます

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

4

2 に答える 2

2

さらに調査した結果、いくつかの解決策を見つけたと思います。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-10T20:50:11.113 に答える
0

私はその機能を使用したことがないので、ユーザーのお気に入りをリクエストするときにこれができるかどうかはわかりませんが、検索語を介してビデオをリクエストするときは、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));
于 2011-01-06T16:50:45.220 に答える