I am using Youtube data api PHP SDK to search for a term and then I tested the code below to search for 'apple' and the first result I get is a video of justin bieber.. am I going nuts? Why is this and how do I fix it?
<?php
require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path
function printVideoFeed($videoFeed)
{
$count = 1;
foreach ($videoFeed as $videoEntry) {
echo "Entry # " . $count . "\n";
printVideoEntry($videoEntry);
echo "\n";
$count++;
}
}
function printVideoEntry($videoEntry)
{
// see the paragraph above this function for more information on the
// 'mediaGroup' object. in the following code, we use the mediaGroup
// object directly to retrieve its 'Mobile RSTP link' child
foreach ($videoEntry->mediaGroup->content as $content) {
//if ($content->type === "video/quicktime") {
echo 'Mobile RTSP link: ' . $content->url . "\n";
//}
}
}
Zend_Loader::loadClass('Zend_Gdata_YouTube');
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy('viewCount');
$query->setSafeSearch('none');
$query->setVideoQuery('apple');
//$query->setMaxResults(1);
// 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);
?>You received this message because you are subscribed to the Google Groups "YouTube APIs Developer Forum" group.
To post to this group, send email to youtube-api-gdata@googlegroups.com.
To unsubscribe from this group, send email to youtube-api-gdata+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/youtube-api-gdata?hl=en.
No comments:
Post a Comment