本文整理汇总了PHP中Zend_Gdata_YouTube::getFeed方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::getFeed方法的具体用法?PHP Zend_Gdata_YouTube::getFeed怎么用?PHP Zend_Gdata_YouTube::getFeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube::getFeed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVideos
/**
* Retrieve user's uploaded videos.
*
* @param $maxResults int
* Maximum number of YoutubeVideo to return.
* @return array(YoutubeVideo) Videos retrieved.
*/
public function getVideos($maxResults)
{
try {
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(WSW_Main::$plugin_dir) . '/lib/Youtube');
if (!class_exists('Zend_Loader')) {
require_once 'Zend/Loader.php';
}
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_YouTube');
// If the keyword is compoused, divide each word
$key_phrase = $this->keyword;
$key_phrase_arr = explode(' ', $key_phrase);
$query_url = Zend_Gdata_YouTube::VIDEO_URI . "/-/";
foreach ($key_phrase_arr as $key_phrase_item) {
if (trim($key_phrase_item) != '') {
$query_url .= trim($key_phrase_item) . '/';
}
}
//$query_url .= '?v=2';
$query = new Zend_Gdata_Query($query_url);
$query->setMaxResults($maxResults);
$query->setParam('orderby', 'viewCount');
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$videoFeed = $yt->getFeed($query, 'Zend_Gdata_YouTube_VideoFeed');
// TODO See how this initialization must be done, I mean if is really neccesary
$keyVideos = array();
foreach ($videoFeed as $videoEntry) {
$keyVideos[] = new WSW_YoutubeVideo($videoEntry);
}
return $keyVideos;
} catch (Exception $e) {
// Store to log
$msg_to_log = 'Error while getVideos from Youtube, Url: ' . $query_url . ', Exception Msg: ' . $e->getMessage();
return array();
}
}
示例2: getRelatedVideos
/**
*
* @param $maxResults int
* Maximum number of YoutubeVideo to return.
* @return array(YoutubeVideo) Videos retrieved.
*/
public function getRelatedVideos($maxResults)
{
try {
if (!class_exists('Zend_Loader')) {
require_once WPPostsRateKeys::$plugin_dir . 'classes/YoutubeWordpress/Zend/Loader.php';
}
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$query = new Zend_Gdata_Query(Zend_Gdata_YouTube::VIDEO_URI . "/{$this->videoEntry->getVideoId()}/" . Zend_Gdata_YouTube::RELATED_URI_SUFFIX);
$query->setMaxResults($maxResults);
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$relatedVideosFeed = $yt->getFeed($query, 'Zend_Gdata_YouTube_VideoFeed');
// TODO See how this initialization must be done, I mean if is really neccesary.
$relatedVideos = array();
foreach ($relatedVideosFeed as $relatedVideoEntry) {
$relatedVideos[] = new YoutubeVideo($relatedVideoEntry);
}
return $relatedVideos;
} catch (Exception $e) {
// Store to log
$msg_to_log = 'Error while getRelatedVideos from Youtube' . ', Exception Msg: ' . $e->getMessage();
// Add log
WPPostsRateKeys_Logs::add_error('362', $msg_to_log);
return array();
}
}