本文整理汇总了PHP中Zend_Gdata_YouTube::getVideoFeed方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::getVideoFeed方法的具体用法?PHP Zend_Gdata_YouTube::getVideoFeed怎么用?PHP Zend_Gdata_YouTube::getVideoFeed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Gdata_YouTube
的用法示例。
在下文中一共展示了Zend_Gdata_YouTube::getVideoFeed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: searchAndPrint
function searchAndPrint($searchTerms = 'sesame street')
{
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy('relevance');
$query->setSafeSearch('moderate');
$query->setVideoQuery($searchTerms);
$query->setParam('caption', 'true');
$query->setParam('start-index', $_GET['start_index']);
$query->setParam('max-results', 8);
//$query->setParam('max-results','2');
// Note that we need to pass the version number to the query URL function
// to ensure backward compatibility with version 1 of the API.
//echo $query->getQueryUrl(2);
//$videoFeed = $yt->getVideoFeed("http://gdata.youtube.com/feeds/api/videos?orderby=relevance&safeSearch=moderate&q=sesame+street");
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
$links = $videoFeed->getLink();
$suggestFlag = null;
foreach ($links as $link) {
if ($link->getRel() == 'http://schemas.google.com/g/2006#spellcorrection') {
$videoFeed = $yt->getVideoFeed($link->getHref());
//print_r($link->getTitle());
$suggestFlag = $link->getTitle();
break;
}
}
//if($links[1]){
//}
printVideoFeed($videoFeed, $suggestFlag);
//'Search results for: ' . $searchTerms);
}
示例2: getAndPrintVideoFeed
function getAndPrintVideoFeed($location = Zend_Gdata_YouTube::VIDEO_URI)
{
$yt = new Zend_Gdata_YouTube();
// set the version to 2 to receive a version 2 feed of entries
$yt->setMajorProtocolVersion(2);
$videoFeed = $yt->getVideoFeed($location);
printVideoFeed($videoFeed);
}
示例3: searchOnYT
/**
* Функция получения результатов поиска по серверу YT в виде объекта VideoFeed.
* @param string $searchString строка поиска.
* @return VideoFeed - возвращает объект VideoFeed
*/
function searchOnYT($searchString, $startID = 0)
{
$yt = new Zend_Gdata_YouTube($this->authYT($username, $password));
$query = $yt->newVideoQuery();
$query->videoQuery = $searchString;
$query->startIndex = $startID;
$query->maxResults = VideoThing::FILES_COUNT;
$query->orderBy = 'viewCount';
//echo $query->queryUrl . "\n <br />";
$videoFeed = $yt->getVideoFeed($query);
return $videoFeed;
}
示例4: getCategoryVideos
/**
* Retrieve video of based upon a given category
*
* @access public
* @param int $maxResults
* @return gVideo
*/
public function getCategoryVideos($maxResults = 15)
{
if ($this->getCategory() == '') {
throw new Exception("Empty categories are not allowed");
} else {
try {
$yt = new Zend_Gdata_YouTube();
$query = $yt->newVideoQuery();
$query->category = $this->getCategory();
$query->maxResults = $maxResults;
$videoFeed = $yt->getVideoFeed($query);
foreach ($videoFeed as $videoEntry) {
$gVideo = new CW_Google_Video_YouTube('', $videoEntry->mediaGroup->title->text, $videoEntry->getPublished(), $videoEntry->getId(), $videoEntry->updated->text, $videoEntry->mediaGroup->duration->seconds, $videoEntry->mediaGroup->content[0]->medium, $videoEntry->comments->feedLink->getHref(), $videoEntry->mediaGroup->content[0]->url, $videoEntry->mediaGroup->keywords->text, $videoEntry->mediaGroup->thumbnail[0]->url, $videoEntry->mediaGroup->thumbnail[0]->width, $videoEntry->mediaGroup->thumbnail[0]->height, $videoEntry->mediaGroup->thumbnail[0]->time, $videoEntry->mediaGroup->player[0]->url, $videoEntry->mediaGroup->category[0]->text, $videoEntry->getContent(), $videoEntry->mediaGroup->description->text, $videoEntry->getRating(), $videoEntry->getRacy(), $videoEntry->getStatistics()->getViewCount());
$this->setVideos($gVideo);
}
} catch (Zend_Gdata_App_Exception $ex) {
print $ex->getMessage();
} catch (Exception $e) {
print $e->getMessage();
}
}
return $this->getVideos();
}
示例5: video
function video()
{
$videoId = $this->params['id'];
$yt = new Zend_Gdata_YouTube();
$entry = $yt->getVideoEntry($videoId);
$this->set('videoTitle', $entry->mediaGroup->title);
$this->set('description', $entry->mediaGroup->description);
$this->set('authorUsername', $entry->author[0]->name);
$this->set('authorUrl', 'http://www.youtube.com/profile?user=' . $entry->author[0]->name);
$this->set('tags', $entry->mediaGroup->keywords);
$this->set('duration', $entry->mediaGroup->duration->seconds);
$this->set('watchPage', $entry->mediaGroup->player[0]->url);
$this->set('viewCount', $entry->statistics->viewCount);
$this->set('rating', $entry->rating->average);
$this->set('numRaters', $entry->rating->numRaters);
/* Get related Videos */
$ytQuery = $yt->newVideoQuery();
$ytQuery->setFeedType('related', $videoId);
$ytQuery->setOrderBy('rating');
$ytQuery->setMaxResults(5);
$ytQuery->setFormat(5);
$this->set('videoId', $videoId);
$this->set('related', $yt->getVideoFeed($ytQuery));
}
示例6: getYoutubeVideoSuggestions
public function getYoutubeVideoSuggestions()
{
if (Mage::helper('videogallery')->isVideoSuggestionsEnabled() == false) {
return array();
}
if (!$this->_youtubeFeed) {
try {
$product = $this->getProduct();
if (!$product->getId()) {
return array();
}
$yt = new Zend_Gdata_YouTube();
$yt->getHttpClient()->setConfig(array('timeout' => 10));
$query = $yt->newVideoQuery();
$query->videoQuery = $product->getName() . ' ' . $product->getSku();
$query->startIndex = 0;
$query->maxResults = 5;
$results = $yt->getVideoFeed($query);
$this->_youtubeFeed = array();
foreach ($results as $video) {
if ($this->videoAlreadyAdded($video->getVideoId())) {
continue;
}
$this->_youtubeFeed[] = $video;
}
} catch (Exception $e) {
return "Error Retrieving Video Suggestions from Youtube: " . $e->getMessage();
}
}
return $this->_youtubeFeed;
}
示例7: getvideoselectAction
/**
* getvideoselectAction
* @author Thomas Schedler <ths@massiveart.com>
* @version 1.0
*/
public function getvideoselectAction()
{
$this->core->logger->debug('core->controllers->VideoController->getvideoselectAction()');
try {
$arrVideos = array();
$objRequest = $this->getRequest();
$intChannelId = $objRequest->getParam('channelId');
$strChannelUserId = $objRequest->getParam('channelUserId', '');
$strElementId = $objRequest->getParam('elementId');
$strValue = $objRequest->getParam('value');
$strSearchQuery = $objRequest->getParam('searchString');
switch ($intChannelId) {
/*
* Vimeo Controller
*/
case $this->core->sysConfig->video_channels->vimeo->id:
/**
* Requires simplevimeo base class
*/
require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php';
$arrChannelUser = $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
$intIdVideoType = 1;
if (array_key_exists('id', $arrChannelUser)) {
// Now lets do the user search query. We will get an response object containing everything we need
$objResponse = VimeoVideosRequest::getList($this->core->sysConfig->video_channels->vimeo->users->user->id);
// We want the result videos as an array of objects
$arrVideos = $objResponse->getVideos();
} else {
if ($strChannelUserId !== '') {
if (is_array($arrChannelUser)) {
foreach ($arrChannelUser as $chUser) {
if ($chUser['id'] == $strChannelUserId) {
// Now lets do the user search query. We will get an response object containing everything we need
$objResponse = VimeoVideosRequest::getList($strChannelUserId);
// We want the result videos as an array of objects
$arrVideos = $objResponse->getVideos();
}
}
}
}
}
// Set Channel Users
$this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $this->core->sysConfig->video_channels->vimeo->users->user->toArray();
break;
/**
* Youtube Controller
*/
/**
* Youtube Controller
*/
case $this->core->sysConfig->video_channels->youtube->id:
$arrChannelUser = $this->core->sysConfig->video_channels->youtube->users->user->toArray();
$intIdVideoType = 2;
$objResponse = new Zend_Gdata_YouTube();
$objResponse->setMajorProtocolVersion(2);
if (array_key_exists('id', $arrChannelUser) && $strSearchQuery === '') {
$arrVideos = $objResponse->getuserUploads($this->core->sysConfig->video_channels->youtube->users->user->id);
} else {
if ($strChannelUserId !== '') {
$arrVideos = $objResponse->getuserUploads($strChannelUserId);
} else {
if ($strSearchQuery !== '') {
$query = $objResponse->newVideoQuery();
$query->setOrderBy('viewCount');
$query->setSafeSearch('none');
$query->setVideoQuery($strSearchQuery);
$arrVideos = $objResponse->getVideoFeed($query->getQueryUrl(2));
}
}
}
// Set Channel Users
$this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array() : $this->core->sysConfig->video_channels->youtube->users->user->toArray();
break;
}
$this->view->idVideoType = $intIdVideoType;
$this->view->elements = $arrVideos;
$this->view->channelUserId = $strChannelUserId;
$this->view->value = $strValue;
$this->view->elementId = $strElementId;
} catch (Exception $exc) {
$this->core->logger->err($exc);
exit;
}
}
示例8: searchRandomVideo
function searchRandomVideo($searchTerms)
{
global $maxSearchResults;
//error_log("max results " . $maxSearchResults);
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
// $query->setOrderBy('relevance');
// $query->setOrderBy('viewCount');
// $query->setOrderBy('random');
$query->setSafeSearch('none');
$query->setVideoQuery($searchTerms);
$query->setMaxResults($maxSearchResults);
// Note that we need to pass the version number to the query URL function
// to ensure backward compatibility with version 1 of the API.
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
// printVideoFeed($videoFeed, 'Search results for: ' . $searchTerms);
$randVideoEntry = getRandomVideo($videoFeed);
return $randVideoEntry;
}
示例9: executeSearchYoutube
public function executeSearchYoutube(sfWebRequest $request)
{
ini_set('display_errors', false);
$util = new Util();
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setSafeSearch('none');
$query->setMaxResults(10);
$query->setVideoQuery($request->getPostParameter('data'));
// Note that we need to pass the version number to the query URL function
// to ensure backward compatibility with version 1 of the API.
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
$html = $util->printVideoFeed($videoFeed);
echo $html;
return sfView::NONE;
}
示例10: getRelevantVideos
function getRelevantVideos($searchTerms, $maxResults = 50)
{
if ($maxResults > 50) {
$maxResults = 50;
// No more than 50 results allowed by Youtube.com
}
try {
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy('relevance');
$query->setSafeSearch('none');
$query->setMaxResults($maxResults);
$query->setVideoQuery($searchTerms);
// Note that we need to pass the version number to the query URL function
// to ensure backward compatibility with version 1 of the API.
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
return $videoFeed;
} catch (Zend_Gdata_App_HttpException $httpException) {
//echo ("App HttpException Thrown<br>\n");
$response = $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
//echo ("App Exception Thrown<br>\n");
$response = $e->getMessage();
} catch (Exception $except) {
//echo ("Exception Thrown<br>\n");
$response = $except->getMessage();
}
echo "Error: {$response}<br>";
return null;
}
示例11: array
*/
if (isset($_GET['search'])) {
/*
* Loading the Zend GDATA API.
*/
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_App_Exception');
$youTubeService = new Zend_Gdata_YouTube();
$query = $youTubeService->newVideoQuery();
$query->setQuery($_POST['search']);
$query->setStartIndex(0);
$query->setMaxResults(9);
$query->setFormat('5');
$feed = $youTubeService->getVideoFeed($query);
/* Grabs the data received from Gdata and converts it into a nice array
for people like me to work with. Its just so I handle the data better.
It basically puts in the title of the video, the ID of the video,
the link to the video and the URL of the largest thumbnail possible */
$i = 0;
$youtubeData = array();
foreach ($feed as $entry) {
$youtubeData[$i]['title'] = $entry->getVideoTitle();
$youtubeData[$i]['id'] = $entry->getVideoId();
$youtubeData[$i]['video'] = $entry->getFlashPlayerUrl();
$thumbnail = $entry->getVideoThumbnails();
$youtubeData[$i]['img'] = $thumbnail[2]['url'];
$i++;
}
//end data parsing
示例12: array
$matches = array();
$result = mysql_query("SELECT * FROM matchids WHERE " . $crawl_string . " or sessionid = 680462533 LIMIT 0, 10");
while ($row = mysql_fetch_array($result)) {
if ($row['sessionid'] > 1000000) {
$matches["match_" . strtolower(dechex($row['sessionid']))] = $row;
}
}
echo 'Crawling ' . count($matches) . ' match(es)<br/>';
$matchlist = implode(' | ', array_keys($matches));
if (empty($matchlist)) {
die;
}
echo $matchlist . "<br/>";
$query = $yt->newVideoQuery();
$query->setVideoQuery($matchlist);
$query->setMaxResults(50);
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
foreach ($videoFeed as $videoEntry) {
preg_match_all("/(Scout|Soldier|Pyro|Demoman|Heavy|Engineer|Medic|Sniper|Spy)|match_([0-9a-f]{6,})/", implode("|", $videoEntry->getVideoTags()), $matchid);
$authobj = $videoEntry->getAuthor();
$matchinfo = $matches[$matchid[0][1]];
if (mysql_num_rows(mysql_query("SELECT youtubeid FROM videos WHERE youtubeid = '" . $videoEntry->getVideoId() . "'")) != 0) {
mysql_query("UPDATE videos SET title = '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', description = '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' WHERE youtubeid = '" . $videoEntry->getVideoId() . "'");
echo mysql_error();
} else {
$nextmatch = mysql_fetch_array(mysql_query("SELECT * FROM matchids WHERE matchdate > '" . $matchinfo['matchdate'] . "' AND serverid = " . $matchinfo['serverid'] . " LIMIT 1"));
mysql_query("INSERT INTO videos ( youtubeid, youtubeuser, map, sessionid, matchdate, matchduration, role, serverid, duration, title, description ) VALUES ( '" . $videoEntry->getVideoId() . "', '" . $authobj[0]->getName() . "', '" . $matchinfo['mapname'] . "', '" . $matchinfo['sessionid'] . "', '" . $matchinfo['matchdate'] . "', '" . (strtotime($nextmatch['matchdate']) - strtotime($matchinfo['matchdate'])) . "', '" . $matchid[0][0] . "', '" . $matchinfo['serverid'] . "', '" . $videoEntry->getVideoDuration() . "', '" . mysql_real_escape_string($videoEntry->getVideoTitle()) . "', '" . mysql_real_escape_string($videoEntry->getVideoDescription()) . "' )");
echo mysql_error();
$yt->insertEntry($videoEntry, $yt->getUserFavorites("LethalZone")->getSelfLink()->href);
}
}
示例13: catch
require_once '/usr/share/php/libzend-framework-php/Zend/Gdata/YouTube.php';
// Enter your Google account credentials
$username = 'stanford.crypto@gmail.com';
$passwd = 'Iks0jfisdf0mq2KKx';
$authenticationURL = 'https://www.google.com/accounts/ClientLogin';
try {
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username, $passwd, $service = 'youtube', $client = null, $source = 'MySource', $loginToken = null, $loginCaptcha = null, $authenticationURL);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
echo 'URL of CAPTCHA image: ' . $cre->getCaptchaUrl() . "\n";
echo 'Token ID: ' . $cre->getCaptchaToken() . "\n";
} catch (Zend_Gdata_App_AuthException $ae) {
echo 'Problem authenticating: ' . $ae->exception() . "\n";
}
$developerKey = "AI39si6XnLpHKQofAlknA2RvYaGTmAIi3oaaF06IT7ibI_2QM-M_QSdoD9bPZ5AIiqfKceCETIhZg1smyIc8yFhBawS9zoCFnA";
$applicationId = "Online Course";
$clientId = "";
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setAuthor($username);
$query->setMaxResults(50);
//echo $query->getQueryUrl(2);
$start = 1;
while ($start % 50 == 1) {
$feed = $yt->getVideoFeed("http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=50&start-index=" . $start);
foreach ($feed as $video) {
echo $video->getVideoId() . ":" . $video->getVideoTitle() . " \n";
file_put_contents($video->getVideoTitle() . '/vidID.json', json_encode($video->getVideoID()));
$start++;
}
}
示例14: array
// libs
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
require_once "lib/youtube.lib.inc.php";
require_once $library_path . DIRECTORY_SEPARATOR . 'cache.php';
if ((int) $_REQUEST['page'] != 0) {
$prev = $_REQUEST['page'] - 1;
$next = $_REQUEST['page'] + 1;
$index = $_REQUEST['page'] * 5 - 4;
} else {
$next = 2;
$index = 1;
}
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setMaxResults(5);
$query->setAuthor($youtube_user);
$query->setOrderBy('updated');
$query->setStartIndex($index);
$cache = mwosp_get_cache();
$cache_id = md5($query->getQueryUrl());
$uploads = array();
// XXX: Workaround for deserialization
Zend_Loader::loadClass('Zend_Http_Client_Adapter_Socket');
if (($uploads = $cache->load($cache_id)) === false) {
$uploads = $yt->getVideoFeed($query);
$cache->save($uploads, $cache_id);
}
require "templates/{$prefix}/index.html";
$page->output();
示例15: searchAndPrint
function searchAndPrint($searchTerms = '')
{
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy('relevance');
$query->setSafeSearch('none');
$query->setVideoQuery($searchTerms);
// Note that we need to pass the version number to the query URL function
// to ensure backward compatibility with version 1 of the API.
$videoFeed = $yt->getVideoFeed($query->getQueryUrl(2));
$this->printVideoFeed($videoFeed, 'Search results for: ' . $searchTerms);
}