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); }
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); }
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)); }