当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Gdata_YouTube::setMajorProtocolVersion方法代码示例

本文整理汇总了PHP中Zend_Gdata_YouTube::setMajorProtocolVersion方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Gdata_YouTube::setMajorProtocolVersion方法的具体用法?PHP Zend_Gdata_YouTube::setMajorProtocolVersion怎么用?PHP Zend_Gdata_YouTube::setMajorProtocolVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Gdata_YouTube的用法示例。


在下文中一共展示了Zend_Gdata_YouTube::setMajorProtocolVersion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 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);
 }
开发者ID:google-code-backups,项目名称:vlc-shares,代码行数:7,代码来源:Youtube.php

示例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);
				}
			}
		}
开发者ID:niczak,项目名称:TweetPHP,代码行数:29,代码来源:YouTubeData.class.php

示例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);
}
开发者ID:nadu,项目名称:open-captions,代码行数:32,代码来源:search.php

示例4: initialize_transport

 /**
  *
  * @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;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:Youtube.php

示例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);
}
开发者ID:aboynejames,项目名称:phplifestylelinking,代码行数:8,代码来源:youtubedaily.php

示例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);
 }
开发者ID:hashir,项目名称:UoA,代码行数:12,代码来源:actions.class.php

示例7: 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]);
}
开发者ID:hurcane,项目名称:tiki-azure,代码行数:60,代码来源:mod-func-last_youtube_playlist_videos.php

示例8: 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);
 }
开发者ID:hashir,项目名称:UoA,代码行数:21,代码来源:entriesTask.class.php

示例9: 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();
     }
 }
开发者ID:Kishor900,项目名称:scrapboard,代码行数:44,代码来源:YoutubeInterface.php

示例10: boostYtAccount

 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;
         }
     }
 }
开发者ID:laiello,项目名称:we-promote-this,代码行数:81,代码来源:WPTYTBoost.php

示例11: getAndPrintUserUploads

function getAndPrintUserUploads($userName)
{
    $username = $_SESSION['username'];
    $query = "select video from user where username='{$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));
}
开发者ID:danielheyman,项目名称:EazySubs,代码行数:21,代码来源:functions.php

示例12: 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;
}
开发者ID:pkmittal81,项目名称:COLLAGE-GMPTube-SAS,代码行数:20,代码来源:fetchagent.php

示例13: 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();
     }
 }
开发者ID:Kishor900,项目名称:scrapboard,代码行数:33,代码来源:YoutubeVideo.php

示例14: testCommentOnAComment

 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);
 }
开发者ID:netvlies,项目名称:zf,代码行数:19,代码来源:YouTubeOnlineTest.php

示例15: getYouTubeService

/**
 * 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;
}
开发者ID:hamik112,项目名称:gdata-samples,代码行数:10,代码来源:get_activity.php


注:本文中的Zend_Gdata_YouTube::setMajorProtocolVersion方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。