2011-01-06 100 views
0

你好我期運用的Zend的GData庫YouTube視頻我試圖表現出更多的則20個視頻或者我可以設定我要多少視頻顯示,但我沒有發現任何選項的Zend的GData庫

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

有一種方式來獲得更多的則20個視頻或更少的Zend的GData默認爲20

您可以查看這裏

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

回答

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)); 
+0

我需要得到用戶的視頻列表限制 – r1400304 2011-01-06 19:03:21

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); 
} 
+0

由於沒有人回答了這個問題更準確,我會獎勵獎金對自己:) – egis 2011-01-17 16:44:46