當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Gdata_YouTube::newVideoQuery方法代碼示例

本文整理匯總了PHP中Zend_Gdata_YouTube::newVideoQuery方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Gdata_YouTube::newVideoQuery方法的具體用法?PHP Zend_Gdata_YouTube::newVideoQuery怎麽用?PHP Zend_Gdata_YouTube::newVideoQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Gdata_YouTube的用法示例。


在下文中一共展示了Zend_Gdata_YouTube::newVideoQuery方法的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);
}
開發者ID:nadu,項目名稱:open-captions,代碼行數:32,代碼來源:search.php

示例2: getVideosByPlaylist

 public function getVideosByPlaylist($playlistId, $page = 0)
 {
     /* @var $ytq Zend_Gdata_YouTube_VideoQuery */
     $ytq = $this->yt->newVideoQuery("http://gdata.youtube.com/feeds/api/playlists/" . $playlistId);
     $page = $page * self::ITEMS_PER_PAGE;
     $ytq->setStartIndex($page == 0 ? $page : $page + 1);
     $ytq->setMaxResults(self::ITEMS_PER_PAGE);
     $ytq->setOrderBy('position');
     return $this->yt->getPlaylistVideoFeed($ytq);
 }
開發者ID:google-code-backups,項目名稱:vlc-shares,代碼行數:10,代碼來源:Youtube.php

示例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;
 }
開發者ID:EntityFX,項目名稱:QuikiJAR,代碼行數:17,代碼來源:Video.php

示例4: getRelatedVideos

/**
 * Returns a feed of videos related to the specified video
 *
 * @param string $videoId The video
 * @return Zend_Gdata_YouTube_VideoFeed The feed of related videos
 */
function getRelatedVideos($videoId)
{
    $yt = new Zend_Gdata_YouTube();
    $ytQuery = $yt->newVideoQuery();
    // show videos related to the specified video
    $ytQuery->setFeedType('related', $videoId);
    // order videos by rating
    $ytQuery->setOrderBy('rating');
    // retrieve a maximum of 5 videos
    $ytQuery->setMaxResults(5);
    // retrieve only embeddable videos
    $ytQuery->setFormat(5);
    return $yt->getVideoFeed($ytQuery);
}
開發者ID:falafflepotatoe,項目名稱:trainsmart-code,代碼行數:20,代碼來源:index.php

示例5: searchAndPrint

function searchAndPrint($searchTerms)
{
    $yt = new Zend_Gdata_YouTube();
    $yt->setMajorProtocolVersion(2);
    $query = $yt->newVideoQuery();
    $query->setOrderBy('relevance');
    //$query->setSafeSearch('moderate');
    $query->settime('today');
    $query->setMaxResults(6);
    $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));
    printVideoFeed($videoFeed);
    //, 'Search results for: ' . $searchTerms);
}
開發者ID:aboynejames,項目名稱:phplifestylelinking,代碼行數:16,代碼來源:youtubedaily.php

示例6: 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();
 }
開發者ID:kwylez,項目名稱:CW-Google,代碼行數:30,代碼來源:Util.php

示例7: 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));
 }
開發者ID:simonescu,項目名稱:mashupkeyword,代碼行數:24,代碼來源:youtube_controller.php

示例8: youtubeSearch

 /**
  * youtube search
  * using Zend_Gdate_YouTube() class
  *
  */
 public function youtubeSearch($keyword = null, $per_page = '25', $start_index = '1')
 {
     $yt = new Zend_Gdata_YouTube();
     $yt_query = $yt->newVideoQuery();
     $yt_query->videoQuery = urlencode($keyword);
     $yt_query->startIndex = $start_index;
     $yt_query->maxResults = $per_page;
     $yt_query->orderBy = 'viewCount';
     $yt_query->Format = '5';
     $request = $yt->getVideoFeed($yt_query);
     if (!$request) {
         throw new Exception("There was an error loading the youtubeSearch Data ");
     }
     return $request;
 }
開發者ID:simonescu,項目名稱:mashupkeyword,代碼行數:20,代碼來源:mashup.php

示例9: 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;
 }
開發者ID:xiaoguizhidao,項目名稱:bb,代碼行數:31,代碼來源:Content.php

示例10: testQueryExclamationMarkRemoveBug

 /**
  * @group ZF-8720
  */
 public function testQueryExclamationMarkRemoveBug()
 {
     $yt = new Zend_Gdata_YouTube();
     $query = $yt->newVideoQuery();
     $location = '37.42307,-122.08427';
     $this->assertNull($query->setLocation($location));
     $this->assertEquals($location, $query->getLocation());
     $location = '37.42307,-122.08427!';
     $this->assertNull($query->setLocation($location));
     $this->assertEquals($location, $query->getLocation());
 }
開發者ID:robertfoleyjr,項目名稱:robertfoleyjr-d6,代碼行數:14,代碼來源:VideoQueryTest.php

示例11: 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

示例12: 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;
 }
開發者ID:nass600,項目名稱:homeCENTER,代碼行數:17,代碼來源:actions.class.php

示例13: array

    $crawl_string .= ($i == 0 ? '' : ' OR ') . 'matchdate BETWEEN FROM_UNIXTIME(' . ($period - CRAWLER_REPEAT_PERIOD * $i - CRAWLER_RANGE) . ") AND FROM_UNIXTIME(" . ($period - CRAWLER_REPEAT_PERIOD * $i) . ")";
}
$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);
開發者ID:Zipcore,項目名稱:SSMS,代碼行數:31,代碼來源:crawler.php

示例14: array

 * DEPENDENCIES: PHP 5.2.4+, ZEND FRAMEWORK, GDATA API
 *
 * This script expects an operation variable from the URI.
 * This can include: search, confirm, submit
 *
 */
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();
開發者ID:sjlu,項目名稱:fb-music-app,代碼行數:31,代碼來源:app.youtube.php

示例15: 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;
 }
開發者ID:laiello,項目名稱:we-promote-this,代碼行數:31,代碼來源:YoutubeUploader.php


注:本文中的Zend_Gdata_YouTube::newVideoQuery方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。