本文整理汇总了PHP中Zend_Gdata_YouTube类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube类的具体用法?PHP Zend_Gdata_YouTube怎么用?PHP Zend_Gdata_YouTube使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Gdata_YouTube类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: swfAction
/**
* action swf untuk nampilin video $_uname swf player
*/
public function swfAction()
{
$youtube = new Zend_Gdata_YouTube();
try {
$lists = $youtube->getUserUploads(self::$_uname);
} catch (Exception $ex) {
echo $ex->getMessage();
exit;
}
// masih ngawur, masih belum selesai, klo dibikin gini cuma keluar 1 video :p
// ntar aja dilanjut, ngantukkkkkkkkkkkkkkkkk
foreach ($lists as $vids) {
$pub = new Zend_Date($vids->getPublished()->getText(), Zend_Date::ISO_8601);
// lempar ke view script
$this->view->videoTitle = $this->view->escape($vids->getVideoTitle());
$this->view->published = $pub;
$this->view->videoTags = join(', ', $vids->getVideoTags());
$this->view->desc = $this->view->escape($vids->getVideoDescription());
if ($vids->isVideoEmbeddable()) {
$this->view->url = 'http://www.youtube.com/v/' . $vids->getVideoId() . '&fs=1';
$this->view->width = 320;
$height->view->height = 240;
}
}
}
示例2: getApiComments
public function getApiComments($videoId)
{
echo "Checking for comment on: {$videoId}";
$yt = new Zend_Gdata_YouTube();
// set the version to 2 to retrieve a version 2 feed
$yt->setMajorProtocolVersion(2);
$commentFeed = $yt->getVideoCommentFeed($videoId);
$count = 1;
foreach ($commentFeed as $commentEntry)
{
if (!CommentData::commentExists($commentEntry->id))
{
echo 'YouTube Comment: ' . $commentEntry->title->text . "\n";
$c=CommentData::create();
$c->setMessageId($this->getId());
$c->setCommentId($commentEntry->id);
$c->setComment($commentEntry->content);
$c->setAuthorName($commentEntry->author[0]->name);
$c->setServiceId('3');
$tZulu=$commentEntry->published;
$toStrip=array("T", "Z");
$tZuluStripped=str_replace($toStrip, " ", $tZulu);
$tZuluStrippedUnix=strtotime($tZuluStripped);
$gooddate=date('Y-m-d H:i:s', $tZuluStrippedUnix);
$c->setPermalink($commentEntry->id);
$c->setDate($gooddate);
}
}
}
示例3: 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);
}
示例4: getLastVideos
public function getLastVideos($limit = 5)
{
$ytUser = $this->_usr;
$array = array();
try {
$gdata = new Zend_Gdata_YouTube();
$feed = $gdata->getUserUploads($ytUser);
if ($feed) {
$i = 1;
foreach ($feed as $entry) {
$thumb = max($entry->getVideoThumbnails());
$image = min($entry->getVideoThumbnails());
$date = new Zend_Date($entry->getVideoDuration(), Zend_Date::SECOND);
$array[] = array("id" => $entry->getVideoId(), "title" => $entry->getVideoTitle(), "thumb" => $thumb["url"], "time" => $date->get("mm:ss"), "image" => $image["url"]);
if ($i == $limit) {
break;
/* Sai */
}
$i++;
}
}
} catch (Zend_Exception $e) {
}
return $array;
}
示例5: 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);
}
示例6: moveVideo
/**
* YT API KEY: AI39si53nkZgrhA-nJLOurfN5yOdLdQeWHK_M08w1A19kfwa718lRXR8Dilcpnc1D0BVXn8KLAfSyYdYbdrd3X7bgDV0ma59Zg
*/
public function moveVideo($video)
{
ProjectConfiguration::registerZend();
$httpClient = Zend_Gdata_ClientLogin::getHttpClient('manuel.oteroborjas@adelaide.edu.au', 'watchm3now', 'youtube', null, 'lifeimpact', null, null, 'https://www.google.com/accounts/ClientLogin');
$applicationId = 'lifeimpact';
$clientId = 'lifeimpact';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, YOUTUBE_DEVELOPER_KEY);
$yt->setMajorProtocolVersion(2);
}
示例7: acceptAllContacts
function acceptAllContacts($userName)
{
$yt = new Zend_Gdata_YouTube();
$contactsFeed = $yt->getContactFeed($userName);
foreach ($contactsFeed as $contactsEntry) {
$contactEntry->setStatus($yt->newStatus('accepted'));
$contactEntry->save();
}
}
示例8: module_last_youtube_playlist_videos
/**
* @param $mod_reference
* @param $module_params
*/
function module_last_youtube_playlist_videos($mod_reference, $module_params)
{
global $smarty, $prefs;
$tikilib = TikiLib::lib('tiki');
$data = array();
if (!empty($module_params['id'])) {
$id = $module_params['id'];
require_once 'lib/wiki-plugins/wikiplugin_youtube.php';
if (!empty($module_params['orderby'])) {
$orderby = $module_params['orderby'];
$feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=' . $orderby;
} else {
$feedUrl = 'http://gdata.youtube.com/feeds/api/playlists/' . $id . '?orderby=position';
}
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$yt->setHttpClient($tikilib->get_http_client());
try {
$playlistVideoFeed = $yt->getPlaylistVideoFeed($feedUrl);
$data[$id]['info']['title'] = $playlistVideoFeed->title->text;
// Prepare params for video display
$params = array();
$params['width'] = isset($module_params['width']) ? $module_params['width'] : 425;
$params['height'] = isset($module_params['height']) ? $module_params['height'] : 350;
// Get information from all videos from playlist
// Limit to $module_rows first videos if $module_rows is set
$count_videos = 1;
foreach ($playlistVideoFeed as $videoEntry) {
$videoId = $videoEntry->getVideoId();
$data[$id]['videos'][$videoId]['title'] = $videoEntry->getVideoTitle();
$data[$id]['videos'][$videoId]['uploaded'] = $videoEntry->mediaGroup->uploaded->text;
$data[$id]['videos'][$videoId]['description'] = $videoEntry->getVideoDescription();
$params['movie'] = $videoId;
$pluginstr = wikiplugin_youtube('', $params);
$len = strlen($pluginstr);
//need to take off the ~np~ and ~/np~ at the beginning and end of the string returned by wikiplugin_youtube
$data[$id]['videos'][$videoId]['xhtml'] = substr($pluginstr, 4, $len - 4 - 5);
if (isset($module_rows) && $module_rows > 0 && $count_videos >= $module_rows) {
break;
}
$count_videos++;
}
} catch (Exception $e) {
$data[$id]['info']['title'] = tra('No Playlist found');
$data[$id]['videos'][0]['title'] = $e->getMessage();
}
} else {
$id = 0;
$data[$id]['info']['title'] = tra('No Playlist found');
$data[$id]['videos'][0]['title'] = tra('No Playlist ID was provided');
}
$smarty->assign('verbose', isset($module_params['verbose']) ? $module_params['verbose'] : 'y');
$smarty->assign('link_url', isset($module_params['link_url']) ? $module_params['link_url'] : '');
$smarty->assign('link_text', isset($module_params['link_text']) ? $module_params['link_text'] : 'More Videos');
$smarty->assign_by_ref('data', $data[$id]);
}
示例9: testSetClientIDAndDeveloperKeyHeader
public function testSetClientIDAndDeveloperKeyHeader()
{
$applicationId = 'MyTestCompany-MyTestApp-0.1';
$clientId = 'MyClientId';
$developerKey = 'MyDeveloperKey';
$httpClient = new Zend_Http_Client();
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);
$this->assertTrue($yt instanceof Zend_Gdata_YouTube);
$client = $yt->getHttpClient();
$this->assertEquals($client->getHeader('X-Gdata-Key'), 'key=' . $developerKey);
$this->assertEquals($client->getHeader('X-Gdata-Client'), $clientId);
}
示例10: getYtVideos
public function getYtVideos()
{
$converted_values = array();
$gdata = new Zend_Gdata_YouTube();
$feed = $gdata->getUserUploads($this->_config->getConfiguracao(CFG_YOUTUBE));
foreach ($feed as $entry) {
/* @var $entry Zend_Gdata_YouTube_VideoEntry */
$thumbnail = $entry->getVideoThumbnails();
$date = new Zend_Date($entry->getPublished());
$converted_values[$entry->getVideoId()] = array('video_id' => $entry->getVideoId(), 'nm_title' => $entry->getVideoTitle(), 'tx_description' => $entry->getVideoDescription(), 'thumbnail_small' => $thumbnail[0]['url'], 'thumbnail_big' => $thumbnail[2]['url'], 'nu_time' => $entry->getVideoDuration(), 'dt_upload' => $date->get('yyyy-MM-dd'));
}
return $converted_values;
}
示例11: delete
function delete($username, $password, $source, $videoId)
{
$httpClient = $this->clientLogin($username, $password, $source);
$httpClient->setHeaders('X-GData-Key', "key={$source}");
$yt = new Zend_Gdata_YouTube($httpClient);
try {
$videoEntryToDelete = $yt->getVideoEntry($videoId, null, true);
$result = $yt->delete($videoEntryToDelete);
return $result;
} catch (Zend_Gdata_App_HttpException $httpException) {
echo $httpException->getRawResponseBody();
} catch (Zend_Gdata_App_Exception $e) {
echo $e->getMessage();
}
}
示例12: get_PlaylistEntry_from_Id
/**
*
* @param string $element_id
* @return Zend_Gdata_YouTube_PlaylistListFeed
*/
protected function get_PlaylistEntry_from_Id($element_id)
{
foreach ($this->_api->getPlaylistListFeed('default') as $playlist_entry) {
if ($element_id == $playlist_entry->getPlaylistId()->getText()) {
return $playlist_entry;
}
}
return null;
}
示例13: upload
public static function upload($asset)
{
try {
$credentials = Asset_Video_Youtube::getYoutubeCredentials();
if (!$credentials) {
return;
}
$httpClient = Zend_Gdata_ClientLogin::getHttpClient($username = $credentials["username"], $password = $credentials["password"], $service = 'youtube', $client = Pimcore_Tool::getHttpClient("Zend_Gdata_HttpClient"), $source = 'Pimcore', $loginToken = null, $loginCaptcha = null, 'https://www.google.com/youtube/accounts/ClientLogin');
$httpClient->setConfig(array("timeout" => 3600));
$apikey = $credentials["apiKey"];
$httpClient->setHeaders('X-GData-Key', "key={$apikey}");
$yt = new Zend_Gdata_YouTube($httpClient);
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();
$filesource = $yt->newMediaFileSource($asset->getFileSystemPath());
$filesource->setContentType($asset->getMimetype());
$filesource->setSlug($asset->getFilename());
$myVideoEntry->setMediaSource($filesource);
$myVideoEntry->setVideoTitle($asset->getFullPath());
$myVideoEntry->setVideoDescription($asset->getFullPath());
$myVideoEntry->setVideoCategory('Comedy');
// Set keywords, note that this must be a comma separated string
// and that each keyword cannot contain whitespace
$myVideoEntry->SetVideoTags('---, ---');
// Optionally set some developer tags
$myVideoEntry->setVideoDeveloperTags(array('mydevelopertag', 'anotherdevelopertag'));
// Upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/users/default/uploads';
try {
$newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
$asset->setCustomSetting("youtube", array("id" => strval($newEntry->getVideoId())));
$asset->save();
return true;
} catch (Exception $e) {
$asset->setCustomSetting("youtube", array("failed" => true));
$asset->save();
}
} catch (Exception $e) {
Logger::error($e);
}
return false;
}
示例14: youtubeEntry
function youtubeEntry()
{
ini_set("display_errors", 0);
/**
* credentials
*/
define('EMAIL_ID', 'uoatest7@gmail.com');
define('EMAIL_PASS', 'uoatest@7');
define('YOUTUBE_DEVELOPER_KEY', 'AI39si4DVYjRr1KL17gdDJwosRs4eUblWKBKB7rbqV90Ku1jDye7rVjXbZ_2KaZGiqcDeJBhDYgIzFjczF2FQBUslV27bMeJ9Q');
require_once 'lib/vendor/Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(EMAIL_ID, EMAIL_PASS, 'youtube', null, 'UoAyoutube', null, null, 'https://www.google.com/accounts/ClientLogin');
$applicationId = 'Video uploader v1';
$clientId = 'My video upload client - v1';
$yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, YOUTUBE_DEVELOPER_KEY);
$yt->setMajorProtocolVersion(2);
//$videoFeed = $yt->getVideoFeed(Zend_Gdata_YouTube::VIDEO_URI);
$videoFeed = $yt->getuserUploads("uoatest7");
$this->printVideo($videoFeed);
}
示例15: getFromYoutube
/**
* get a new video from from a youtube url
*
* @param $url
* @return Model_Video video object
*/
public function getFromYoutube($url)
{
$urlArray = parse_url($url);
if (!isset($urlArray['query'])) {
throw new Exception('Invalid URL');
}
parse_str($urlArray['query'], $query);
if (!isset($query['v'])) {
throw new Exception('Invalide YouTube Video URL');
}
$youtube_id = $query['v'];
$yt = new Zend_Gdata_YouTube();
try {
$videoEntry = $yt->getVideoEntry($youtube_id);
} catch (Zend_Gdata_App_HttpException $e) {
//YouTube may be down too?
throw new Exception('Invalid YouTube Video URL');
}
$data = array('url' => $url, 'youtube_id' => $youtube_id, 'title' => $videoEntry->getTitleValue());
return new Model_Video($data);
}