public function __construct() { $this->yt = new Zend_Gdata_YouTube(null, 'vlc-shares/' . X_VlcShares::VERSION . ' youtube/' . self::VERSION, null, 'AI39si4HbHoRBg1vlyLlRARR1Bl2TWqUy4LuCFHpS6ZnZ2LxlqbCLrgh8kDBj-7h2lkDs99cvaOZRm-4p-GlEP2rxtD6BZ9dcg'); $this->yt->setMajorProtocolVersion(2); $this->yt->getHttpClient()->setHeaders('User-Agent', 'vlc-shares/' . X_VlcShares::VERSION . ' youtube/' . self::VERSION); $this->yt->setGzipEnabled(true); }
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); } } }
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); }
/** * * @return Bridge_Api_Youtube */ protected function initialize_transport() { $http_client = new Zend_Gdata_HttpClient(); $http_client->setHeaders('Accept', 'application/atom+xml'); $this->_api = new Zend_Gdata_YouTube($http_client, Uuid::uuid4(), $this->conf->get(['main', 'bridge', 'youtube', 'client_id']), $this->conf->get(['main', 'bridge', 'youtube', 'developer_key'])); $this->_api->setMajorProtocolVersion(2); return $this; }
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); }
/** * YT API KEY: AI39si53nkZgrhA-nJLOurfN5yOdLdQeWHK_M08w1A19kfwa718lRXR8Dilcpnc1D0BVXn8KLAfSyYdYbdrd3X7bgDV0ma59Zg */ public function moveVideo($video) { ProjectConfiguration::registerZend(); $httpClient = Zend_Gdata_ClientLogin::getHttpClient('*****@*****.**', '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); }
/** * @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]); }
function youtubeEntry() { ini_set("display_errors", 0); /** * credentials */ define('EMAIL_ID', '*****@*****.**'); 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); }
/** * 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(); } }
function boostYtAccount($uid) { $query = "Select user_id, user_password from users where id={$uid};"; $result = $this->getDBConnection()->queryDB($query); $row = $result->fetch_assoc(); $userName = $row['user_id']; $password = $row['user_password']; //echo("Username: $userName | Password: $password<br>"); $httpClient = $this->getHttpClient($userName, $password); $yt = new Zend_Gdata_YouTube($httpClient, $this->applicationId, $this->clientId, $this->developerKey); $yt->setMajorProtocolVersion(2); $cc = new CommentCreator(); echo "<font color='green'>Acting as user {$userName}</font><br>"; // For all other users foreach ($this->ytAccounts as $otherUserName => $password) { echo "<font color='orange'>Parsing video feed for user {$otherUserName}</font><br>"; $videoFeed = $yt->getuserUploads($otherUserName); $feedCount = 0; do { $feedCount++; foreach ($videoFeed as $videoEntry) { $videoURL = $videoEntry->getVideoWatchPageUrl(); $videoID = $videoEntry->getVideoId(); //$query = "Select id, boosted from post where postURL='".$videoURL."'"; $query = "Select id from boosted where video_id='" . $videoID . "' AND user_id={$uid}"; //echo($query . "<br>"); $result = $this->getDBConnection()->queryDB($query); $resultCount = $result->num_rows; $boosted = true; if ($resultCount == 0) { $boosted = false; } // If videoEntry has not already been boosted if (!$boosted) { echo "<font color='purple'><b>Boosting video " . $videoEntry->getVideoTitle() . "</b><br>"; // Add a 5 star rating to videos if ($this->add5StarRating($yt, $videoEntry)) { echo "Adding 5 stars to video.<br>"; } else { exit(0); } // Add a comment to other users videos if ($this->addCommentToVideo($yt, $videoEntry, $cc->getComment())) { echo "Adding comments to video.<br>"; } else { exit(0); } // Add one of your videos to a response // TODO: Maybe in the future if the respones video can be approaved automatically //if($this->addVideoResponse($yt, $videoEntry, $videoResponseEntry)){ // echo("Adding video response to video.<br>"); //}else{ //exit(0); //} echo "</font>"; $query = "Insert Ignore INTO boosted (user_id, video_id) Values ({$uid},'{$videoID}')"; $this->getDBConnection()->queryDB($query); echo "<b><a href='{$videoURL}'>{$videoURL}</a> NOW boosted!!!</b><br>"; sleep(rand(10, 30)); } else { echo "<u><a href='{$videoURL}'>{$videoURL}</a> already boosted.</u><br>"; } } try { $videoFeed = $videoFeed->getNextFeed(); //var_dump($videoFeed); //echo("<br><br><br>"); } catch (Exception $e) { //echo("NextFeedError: " . $e -> getMessage() . "<br>"); $videoFeed = null; //echo("<font color='blue'>User $otherUserName feed count: $feedCount</font><br>"); } } while (isset($videoFeed)); // Subscribe to other users yt accounts if ($this->subscribeToUserChannel($yt, $otherUserName)) { echo "<font color='red'>Subscribbing to users channel.</font><br>"; } else { continue; } } }
function getAndPrintUserUploads($userName) { $username = $_SESSION['username']; $query = "select video from user where username='******'"; $result = mysql_query($query); $row = mysql_fetch_array($result); $video = $row['video']; ?> <option value="" <?php if ($video == '') { echo 'selected="selected"'; } ?> > None </option> <?php $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); printVideoFeed($yt->getuserUploads($userName)); }
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; }
/** * * @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(); } }
public function testCommentOnAComment() { $developerKey = constant('TESTS_ZEND_GDATA_YOUTUBE_DEVELOPER_KEY'); $clientId = constant('TESTS_ZEND_GDATA_YOUTUBE_CLIENT_ID'); $client = Zend_Gdata_ClientLogin::getHttpClient($this->user, $this->pass, 'youtube', null, 'ZF_UnitTest', null, null, 'https://www.google.com/youtube/accounts/ClientLogin'); $youtube = new Zend_Gdata_YouTube($client, 'ZF_UnitTest', $clientId, $developerKey); $youtube->setMajorProtocolVersion(2); $mostDiscussedFeed = $youtube->getVideoFeed('http://gdata.youtube.com/feeds/api/standardfeeds/most_discussed'); // get first entry $mostDiscussedFeed->rewind(); $firstEntry = $mostDiscussedFeed->current(); $this->assertTrue($firstEntry instanceof Zend_Gdata_YouTube_VideoEntry); $commentFeed = $youtube->getVideoCommentFeed($firstEntry->getVideoId()); // get first comment $commentFeed->rewind(); $firstCommentEntry = $commentFeed->current(); $commentedComment = $youtube->replyToCommentEntry($firstCommentEntry, 'awesome ! (ZFUnitTest-test)'); $this->assertTrue($commentedComment instanceof Zend_Gdata_YouTube_CommentEntry); }
/** * Return a new instance of a v2 YouTube service object * @return Zend_Gdata_YouTube YouTube service object */ function getYouTubeService() { $yt = new Zend_Gdata_YouTube(null, 'YT-UeberActivityViewer', $GLOBALS['ueber-activity-viewer-php_config']['client_id'], $GLOBALS['ueber-activity-viewer-php_config']['dev_key']); $yt->setMajorProtocolVersion(2); return $yt; }
/** * getvideoselectAction * @author Thomas Schedler <*****@*****.**> * @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; } }
function uploadAction() { //echo $this->user.' - '.$this->pass.' - '.$this->gallery; $this->view->headTitle('UNC - Admin website'); $this->view->headLink()->appendStylesheet($this->view->baseUrl().'/application/templates/admin/css/layout.css'); $this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/jquery-1.7.2.min.js','text/javascript'); $this->view->headScript()->appendFile($this->view->baseUrl().'/application/templates/admin/js/hideshow.js','text/javascript'); $form = $this->setForm(); $this->view->form = $form; if($this->_request->isPost()) { if($form->isValid($_POST)) { $title = $this->_request->getPost('title'); $description = $this->_request->getPost('description'); //echo $title.$description;die(); if ($_FILES["file"]["name"]!='') { $dir = dirname($_FILES["file"]["tmp_name"]); $destination = $dir . DIRECTORY_SEPARATOR . $_FILES["file"]["name"]; rename($_FILES["file"]["tmp_name"], $destination); $httpClient = $this->_httpClient(); Zend_Loader::loadClass('Zend_Gdata_YouTube'); $yt = new Zend_Gdata_YouTube($httpClient, 'NIW-App-1.0', '661085061264.apps.googleusercontent.com', 'AI39si4UPUxw1FE5hqSi0Z-B-5z3PIVovbBWKmqiMI3cXJ7lhvjJcABV-eqimb2EeSiuedWK8N9OGOdB1namX1CqqYki8jEfSQ'); $yt->setMajorProtocolVersion(2); $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); $filesource = $yt->newMediaFileSource($destination); $filesource->setContentType('video/quicktime'); $filesource->setSlug($destination); $myVideoEntry->setMediaSource($filesource); $myVideoEntry->setVideoTitle($title); $myVideoEntry->setVideoDescription($description); $myVideoEntry->setVideoCategory('Autos'); $myVideoEntry->SetVideoTags('cars, funny'); $myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag')); // set the video's location -- this is also optional $yt->registerPackage('Zend_Gdata_Geo'); $yt->registerPackage('Zend_Gdata_Geo_Extension'); $where = $yt->newGeoRssWhere(); $position = $yt->newGmlPos('37.0 -122.0'); $where->point = $yt->newGmlPoint($position); $myVideoEntry->setWhere($where); $uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads'; try { $newEntry = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry'); } catch (Zend_Gdata_App_HttpException $httpException) { echo $httpException->getRawResponseBody(); } catch (Zend_Gdata_App_Exception $e) { echo $e->getMessage(); } if(file_exists($destination)) unlink($destination); echo '<script type="text/javascript"> alert("Video đang được upload trên YOUTUBE !"); </script>'; $this->_redirect($this->view->baseUrl().'/../admin/uploadvideo'); // } else echo '<script type="text/javascript">alert("Vui lòng chọn file !");</script>'; } //} $this->view->title = 'Tải lên video'; } }
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); }
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; }
/** * getselectedvideoAction * @author Dominik Mößlang <*****@*****.**> * @version 1.0 */ public function getselectedvideoAction() { $this->core->logger->debug('core->controllers->VideoController->getselectedvideoAction()'); $strVideoTypeName = ''; $intVideoTypeId = ''; $objSelectedVideo = ''; try { $objRequest = $this->getRequest(); $intChannelId = $objRequest->getParam('channelId'); $strElementId = $objRequest->getParam('elementId'); $strValue = $objRequest->getParam('value'); $strChannelUserId = $objRequest->getParam('channelUserId'); $arrSelectedVideo = array(); switch ($intChannelId) { /** * Vimeo Controller */ case $this->core->sysConfig->video_channels->vimeo->id: require_once GLOBAL_ROOT_PATH . 'library/vimeo/vimeo.class.php'; $intVideoTypeId = 1; $strVideoTypeName = "Vimeo"; /** * Get the selected Video */ if (isset($strValue)) { $objResponse = VimeoVideosRequest::getInfo($strValue); $objSelectedVideo = $objResponse->getVideo(); } break; /** * Youtube Controller */ /** * Youtube Controller */ case $this->core->sysConfig->video_channels->youtube->id: $intVideoTypeId = 2; $strVideoTypeName = "YouTube"; $objResponse = new Zend_Gdata_YouTube(); $objResponse->setMajorProtocolVersion(2); /** * Get the selected Video */ if (isset($strValue)) { $objSelectedVideo = $objResponse->getVideoEntry($strValue); } break; } $this->view->strVideoTypeName = $strVideoTypeName; $this->view->intVideoTypeId = $intVideoTypeId; $this->view->objSelectedVideo = $objSelectedVideo; $this->view->strValue = $strValue; $this->view->strElementId = $strElementId; $this->view->strChannelUserId = $strChannelUserId; } catch (Exception $exc) { $this->core->logger->err($exc); exit; } }
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; }
function player_shortcode($atts) { $username = get_option('youtube_user'); //gets the username that was entered in the admin screen //declares the attributes for the video player shortcode $atts = shortcode_atts(array('width' => '450', 'height' => '253', 'videocode' => '', 'description' => 'yes', 'title' => 'yes', 'descriptionlength' => '1000', 'classname' => ''), $atts); global $descriptionlength; //makes $descriptionlength a global variable so the right length descriptions can be passed from the feed function $descriptionlength = $atts['descriptionlength']; //assigns $descriptionlength the desired value. //YouTube classes for Gdata $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); //if there is a defined video to display on page load, load that video. if ($atts['videocode'] != '') { $videoEntry = $yt->getVideoEntry($atts['videocode']); //get Gdata for all the desired video $descriptionlong = $videoEntry->getVideoDescription(); $description = substr($descriptionlong, 0, $atts['descriptionlength']) . "..."; //description set to the desired length //print HTML for the video player $videoplayer = '<div id="playerchart" class="' . $atts['classname'] . '" >'; if ($atts['title'] == 'yes' || $atts['title'] == 'true') { $videoplayer = $videoplayer . '<div id="titlediv" ><b class="title_player" id="title_player">' . $titleplayer . '</b></div>'; } $videoplayer = $videoplayer . '<div class="video_player"><iframe width="' . $atts['width'] . '" height="' . $atts['height'] . '" id="playingvideo" src="http://www.youtube.com/embed/' . $atts['videocode'] . '" frameborder="0" allowfullscreen></iframe></div>'; if ($atts['description'] == 'yes' || $atts['description'] == 'true') { $videoplayer = $videoplayer . '<div class="player_description" id="player_description">' . $description . '</div>'; } $videoplayer = $videoplayer . '</div>'; return $videoplayer; goto a; //skip out the rest of the function } else { $url = 'http://gdata.youtube.com/feeds/api/users/' . $username . '/uploads?orderby=viewCount&max-results=1'; //url for video feed of one video } Zend_Loader::loadClass('Zend_Gdata_YouTube'); $videoFeed = @$yt->getVideoFeed($url); //create feed from URL //loop through feed foreach ($videoFeed as $videoEntry) { $descriptionlong = $videoEntry->getVideoDescription(); //get video description $titleplayer = $videoEntry->getVideoTitle(); //get video title //change video length if longer than desired amount if (strlen($descriptionlong) > $atts['descriptionlength']) { $descriptionlong = $videoEntry->getVideoDescription(); $description = substr($descriptionlong, 0, $atts['descriptionlength']) . "..."; //... to the end of cut description } else { $description = $videoEntry->getVideoDescription(); //if description is shorter than maximum amount assign full description } //print video player from feed data $videoplayer = '<div id="playerchart" class="' . $atts['classname'] . '" >'; $videoplayer = $videoplayer . '<div id="titlediv" ><b id="title_player">' . $titleplayer . '</b></div>'; $videoplayer = $videoplayer . '<div style="margin-right:20px;"><iframe width="450" height="253" id="playingvideo" src="http://www.youtube.com/embed/' . $videoEntry->getVideoId() . '" frameborder="0" allowfullscreen></iframe></div>'; $videoplayer = $videoplayer . '<div id="player_description">' . $description . '</div>'; $videoplayer = $videoplayer . '</div>'; return $videoplayer; break; //end the loop after one cycle to make sure only one player appears. } a: //where the process skips to if specific video is defined for page load. }
<?php require_once '/usr/share/php/libzend-framework-php/Zend/Gdata.php'; require_once '/usr/share/php/libzend-framework-php/Zend/Gdata/ClientLogin.php'; require_once '/usr/share/php/libzend-framework-php/Zend/Gdata/YouTube.php'; // Enter your Google account credentials $username = '******'; $passwd = 'parseitup'; $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 = "AI39si5GlWcy9S4eVFtajbVZk-DjFEhlM4Zt7CYzJG3f2bwIpsBSaGd8SCWts6V5lbqBHJYXAn73-8emsZg5zWt4EUlJJ4rpQA"; $applicationId = "class2go"; $clientId = ""; $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey); $yt->setMajorProtocolVersion(2); $dirs_ary = glob('*', GLOB_ONLYDIR); foreach ($dirs_ary as $dir) { $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry(); $filestring = file_get_contents($dir . '/vidID.json'); $vidID = substr($filestring, 1, -1); echo "{$dir}: {$vidID}\n"; $videoEntry = $yt->getVideoEntry($vidID); echo 'Edit: ' . $videoEntry->getVideoWatchPageUrl() . "\n"; }
/** *Function for making ajax get requests from specific div */ public static function ajaxGet() { $themePath = NET_PATH . "widgets/"; $host = NetActionController::$hostRW; $view = new Zend_View(); $view->addScriptPath($themePath . "templates/"); $url = "http://www.youtube.com/profile_ajax?action_ajax=1&user=nebojsatmc&new=1&box_method=load_playlist_videos_multi&box_name=user_playlist_navigator&playlistName=all"; //$content = '<script type="text/javascript">$(this).parent().load("' . $url . '", function(data){$(this).parent().append(data);});</script>'; $content = ' <!-- ++Begin Video Bar Wizard Generated Code++ --> <!-- // Created with a Google AJAX Search Wizard // http://code.google.com/apis/ajaxsearch/wizards.html --> <!-- // The Following div element will end up holding the actual videobar. // You can place this anywhere on your page. --> <div id="videoBar-bar"> <span style="color:#676767;font-size:11px;margin:10px;padding:4px;">Loading...</span> </div> <!-- Ajax Search Api and Stylesheet // Note: If you are already using the AJAX Search API, then do not include it // or its stylesheet again --> <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&source=uds-vbw" type="text/javascript"></script> <style type="text/css"> @import url("http://www.google.com/uds/css/gsearch.css"); </style> <!-- Video Bar Code and Stylesheet --> <script type="text/javascript"> window._uds_vbw_donotrepair = true; </script> <script src="http://www.google.com/uds/solutions/videobar/gsvideobar.js?mode=new" type="text/javascript"></script> <style type="text/css"> @import url("http://www.google.com/uds/solutions/videobar/gsvideobar.css"); </style> <style type="text/css"> .playerInnerBox_gsvb .player_gsvb { width : 350px; height : 260px; } /* override standard player dimensions */ .playerInnerBox_gsvb .player_gsvb { width : 480px; height : 380px; } </style> <script type="text/javascript"> function LoadVideoBar() { var videoBar; var options = { string_allDone : "", largeResultSet : true, horizontal : true, autoExecuteList : { cycleTime : GSvideoBar.CYCLE_TIME_MEDIUM, cycleMode : GSvideoBar.CYCLE_MODE_LINEAR, executeList : ["ytchannel:nebojsatmc"] } } videoBar = new GSvideoBar(document.getElementById("videoBar-bar"), GSvideoBar.PLAYER_ROOT_FLOATING, options); } // arrange for this function to be called during body.onload // event processing GSearch.setOnLoadCallback(LoadVideoBar); </script> <!-- ++End Video Bar Wizard Generated Code++ --> '; $yt = new Zend_Gdata_YouTube(); $yt->setMajorProtocolVersion(2); $content = JqueryController::printVideoFeed($yt->getuserUploads('nebojsatmc')); //$url = 'http://gdata.youtube.com/feeds/api/users/nebojsatmc/uploads'; //$content = file_get_contents($url); $ajaxContent['content'] = $content; $ajaxContent['host'] = $host; $view->assign($ajaxContent); $scriptName = "jquery-ajaxCall.phtml"; $partialOutput = $view->render($scriptName); return $content; }