当前位置: 首页>>代码示例>>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;未经允许,请勿转载。