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); }
/** * Check the upload status of a video * * @param string $videoId The video to check. * @return string A message about the video's status. */ function checkUpload($videoId) { $httpClient = getAuthSubHttpClient(); $youTubeService = new Zend_Gdata_YouTube($httpClient); $feed = $youTubeService->getuserUploads('default'); $message = 'No further status information available yet.'; foreach ($feed as $videoEntry) { if ($videoEntry->getVideoId() == $videoId) { // check if video is in draft status try { $control = $videoEntry->getControl(); } catch (Zend_Gdata_App_Exception $e) { print 'ERROR - not able to retrieve control element ' . $e->getMessage(); return; } if ($control instanceof Zend_Gdata_App_Extension_Control) { if ($control->getDraft() != null && $control->getDraft()->getText() == 'yes') { $state = $videoEntry->getVideoState(); if ($state instanceof Zend_Gdata_YouTube_Extension_State) { $message = 'Upload status: ' . $state->getName() . ' ' . $state->getText(); } else { print $message; } } } } } print $message; }
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 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; } } }
/** * 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(); $intVideoTypeId = 1; $arrVideos = array(); /** * Get the vimeo video list */ if ($strChannelUserId !== '' && $strChannelUserId !== 'publicAccess' && $strSearchQuery == '') { if (is_array($arrChannelUser)) { foreach ($arrChannelUser as $chUser) { if ($chUser['id'] == $strChannelUserId) { $objResponse = VimeoVideosRequest::getList($strChannelUserId); } } } $arrVideos = $objResponse->getVideos(); } else { if ($strChannelUserId !== '' && isset($strSearchQuery)) { if ($strChannelUserId == 'publicAccess') { $objResponse = VimeoVideosRequest::search($strSearchQuery); } else { $objResponse = VimeoVideosRequest::search($strSearchQuery, $strChannelUserId); } $arrVideos = $objResponse->getVideos(); } } // Set channel Users $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $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(); $intVideoTypeId = 2; $objResponse = new Zend_Gdata_YouTube(); $objResponse->setMajorProtocolVersion(2); if ($strChannelUserId !== '' && $strSearchQuery == '' && $strChannelUserId !== 'publicAccess') { $arrVideos = $objResponse->getuserUploads($strChannelUserId); } else { if (isset($strChannelUserId) && isset($strSearchQuery)) { if ($strChannelUserId !== 'publicAccess') { $arrVideos = $objResponse->getVideoFeed('http://gdata.youtube.com/feeds/api/users/' . $strChannelUserId . '/uploads?q=' . urlencode($strSearchQuery)); } else { $objQuery = $objResponse->newVideoQuery(); $objQuery->setOrderBy('viewCount'); $objQuery->setSafeSearch('none'); $objQuery->setVideoQuery($strSearchQuery); $arrVideos = $objResponse->getVideoFeed($objQuery->getQueryUrl(2)); } } } // Set Channel Users $this->view->channelUsers = array_key_exists('id', $arrChannelUser) ? array(0 => $arrChannelUser) : $this->core->sysConfig->video_channels->youtube->users->user->toArray(); break; } $this->view->videoTypeId = $intVideoTypeId; $this->view->elements = $arrVideos; $this->view->channelUserId = $strChannelUserId; $this->view->value = $strValue; $this->view->elementId = $strElementId; $this->view->SearchQuery = $strSearchQuery; } catch (Exception $exc) { $this->core->logger->err($exc); exit; } }
/** * 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 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; }