Tehnologii Web de Ultima Generatie
youtube api – script de cautare si afisare automata a videoclipurilor
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<meta name=”Keywords” http-equiv=”Keywords” content=”Fabio Capello,football,world cup,germany,england” />
<title>Fashion of hats – summer 2010</title>
</head>
<body>
<h2>keywords this page has: Fabio Capello,football,world cup,germany,england</h2>
<p>random between first and second video order by "most views" on youtube regarding the above keywords</p>
<p> </p>
<?php
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1′);
require_once ‘Zend/Loader.php’;
Zend_Loader::loadClass(‘Zend_Gdata_YouTube’);
$yt = new Zend_Gdata_YouTube();
//——— params———-
$keywords = ‘Fabio Capello,football,world cup,germany,england’;
$order = “relevance”; //you can use relevance, published, viewCount, rating
$width = 660;
$height = 405;
$color1 =’0xDDDDDD’;
$color2 = ‘0×999999′;
$show_description = 1; //0 if not
$show_tags = 1; //0 if not
$display = 1; // 0 – video with most views. 1 – random between fist and second video that matches
//——— params———-
function printVideoEntry($videoEntry)
{
// the videoEntry object contains many helper functions
// that access the underlying mediaGroup object
/*
echo ‘Video: ‘ . $videoEntry->getVideoTitle() . “<br />”;
echo ‘Video ID: ‘ . $videoEntry->getVideoId() . “<br />”;
echo ‘Updated: ‘ . $videoEntry->getUpdated() . “<br />”;
echo ‘Description: ‘ . $videoEntry->getVideoDescription() . “<br />”;
echo ‘Category: ‘ . $videoEntry->getVideoCategory() . “<br />”;
echo ‘Tags: ‘ . implode(“, “, $videoEntry->getVideoTags()) . “<br />”;
echo ‘Watch page: ‘ . $videoEntry->getVideoWatchPageUrl() . “<br />”;
echo ‘Flash Player Url: ‘ . $videoEntry->getFlashPlayerUrl() . “<br />”;
echo ‘Duration: ‘ . $videoEntry->getVideoDuration() . “<br />”;
echo ‘View count: ‘ . $videoEntry->getVideoViewCount() . “<br />”;
echo ‘Rating: ‘ . $videoEntry->getVideoRatingInfo() . “<br />”;
echo ‘Geo Location: ‘ . $videoEntry->getVideoGeoLocation() . “<br />”;
echo ‘Recorded on: ‘ . $videoEntry->getVideoRecorded() . “<br />”;
echo “Thumbnails:<br />”;
$videoThumbnails = $videoEntry->getVideoThumbnails();
foreach($videoThumbnails as $videoThumbnail) {
echo “<img src=’”. $videoThumbnail['url'].”‘”;
echo ‘ height=’ . $videoThumbnail['height'];
echo ‘ width=’ . $videoThumbnail['width'] . “/> “;
}
*/
//<object width=”1300″ height=”765″><param name=”movie” value=”http://www.youtube-nocookie.com/v/_nDF11mR9yo&hl=en_US&fs=1&color1=0×402061&color2=0×9461ca&hd=1&border=1″></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”http://www.youtube-nocookie.com/v/_nDF11mR9yo&hl=en_US&fs=1&color1=0×402061&color2=0×9461ca&hd=1&border=1″ type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”1300″ height=”765″></embed></object>
//<object width=”1300″ height=”765″><param name=”movie” value=”http://www.youtube-nocookie.com/v/_nDF11mR9yo&hl=en_US&fs=1&hd=1&border=1″></param><param name=”allowFullScreen” value=”true”></param><param name=”allowscriptaccess” value=”always”></param><embed src=”http://www.youtube-nocookie.com/v/_nDF11mR9yo&hl=en_US&fs=1&hd=1&border=1″ type=”application/x-shockwave-flash” allowscriptaccess=”always” allowfullscreen=”true” width=”1300″ height=”765″></embed></object>
$video_info = array(
‘videoid’ => $videoEntry->getVideoId(),
‘description’ => $videoEntry->getVideoDescription(),
‘tags’ => implode(“, “, $videoEntry->getVideoTags())
);
return $video_info;
}
function printVideoFeed($videoFeed,$display)
{
$random = rand(0,1);
if( $display == 0 )
{
return printVideoEntry($videoFeed[0]);
}
if( $display == 1 )
{
return printVideoEntry($videoFeed[$random]);
}
}
function searchAndPrint($searchTerms,$display,$order)
{
$yt = new Zend_Gdata_YouTube();
$yt->setMajorProtocolVersion(2);
$query = $yt->newVideoQuery();
$query->setOrderBy($order);
$query->setSafeSearch(‘none’);
$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 printVideoFeed($videoFeed,$display);
}
$video_info = searchAndPrint($keywords,$display,$order);
$output = ”
<object width=’”.$width.”‘ height=’”.$height.”‘>
<param name=’movie’ value=’http://www.youtube.com/v/”.$video_info['videoid'].”&hl=en_US&fs=1?color1=”.$color1.”&&color2=”.$color2.”&hd=1&border=1′</param>
<param name=’allowFullScreen’ value=’true’></param>
<param name=’allowScriptAccess’ value=’always’></param>
<param name=’hd’ value=’1′></param>
<embed src=’http://www.youtube.com/v/”.$video_info['videoid'].”&hl=en_US&fs=1?color1=”.$color1.”&&color2=”.$color2.”&hd=1&border=1′
type=’application/x-shockwave-flash’
allowfullscreen=’true’
allowscriptaccess=’always’
width=’”.$width.”‘ height=’”.$height.”‘>
</embed>
</object>
“;
echo “<div name=’youtube_video’ style=’width=”.$width.”px; height=”.$height.”px’>”;
echo $output;
if( ($show_description!=0) || ($show_tags !=0)){
echo “<div style=’padding:15px’>”;
if($show_description==1) echo $video_info['description'].”<br />”;
if($show_tags==1) echo “Tags: “.$video_info['tags'];
echo “</div>”;
}
echo “</div>”;
?>
<h2>The FA have announced that Fabio Capello will stay on as <a href=”http://uk.eurosport.yahoo.com/football/england/”>England</a> manager despite the team’s woeful performance at the <a href=”http://uk.eurosport.yahoo.com/football/world-cup/”>World Cup</a>.</h2>
<p>And the 64-year-old Italian said he was more determined than ever to succeed after the FA unanimously decided to keep faith with him.</p>
<p>Capello and his squad came under fire after England’s shoddy World Cup performance ended in a humiliating 4-1 last-16 defeat by <a href=”http://uk.eurosport.yahoo.com/football/germany/”>Germany</a> on Sunday.</p>
<p>Shortly before the World Cup began the FA had confirmed that Capello would remain in charge until the 2012 European Championship but the failure in <a href=”http://uk.eurosport.yahoo.com/football/south-africa/”>South Africa</a> cast doubts over his future.</p>
<p>However, after days of speculation it was agreed at a meeting of the Club England Board that Capello, who earns £6 million a year, would remain in charge.</p>
<p>"I am more determined than ever to succeed with the England team," Capello said.</p>
<p>"(Club England chairman) Sir Dave Richards has called me to tell me everyone at the FA wants me to continue. I explained it is very important we use the disappointment as a motivation in the future.</p>
<p>"I can assure the fans I am now fully focused on our European qualifying fixtures, starting with the friendly against Hungary in August.</p>
<p>"I am extremely proud to be the England manager, it means so much to me and I am determined to succeed."</p>
<p>The decision was taken at a meeting between Richards and his fellow Club England board members – former England midfielder Trevor Brooking, Alex Horne and Club England managing director Adrian Bevington – and then approved by the FA’s main board..</p>
<p>"We are all still extremely disappointed at our performance in South Africa, and we believed it was important that we took some time to reflect on everything in a calm and considered manner back in England," Richards said.</p>
<p>"After fully discussing our performance we remain convinced that Fabio is the best man for the job."</p>
<p>Capello’s first task will be to restore public confidence in the squad, and his own abilities.</p>
<p>The former AC Milan and Real Madrid coach’s tactics and selection policy were castigated by the media and public alike as England toiled through the group stage.</p>
<p>A 1-1 draw with the United States and a 0-0 stalemate with Algeria left England needing a 1-0 win over Slovenia to move through to the knockout stages in second place in their group.</p>
<p>England were then outplayed by a youthful Germany side who inflicted their worst ever World Cup defeat.</p>
<p>With an ageing squad, Capello will be under pressure to quickly inject some vitality into the team as European championship qualifiers against Bulgaria and <a href=”http://uk.eurosport.yahoo.com/football/switzerland/”>Switzerland</a> loom.</p>
<p>Frank Lampard and Steven Gerrard have almost certainly played in their last World Cup finals while former captain John Terry, whose outspoken comments were criticised by Capello in South Africa, is also close to 30.</p>
<p>"We will look to introduce new players to give the team new energy and I will use all my experience to take England forward," Capello said.</p>
<h2> </h2>
</body>
</html>
| Print article | This entry was posted by oferta web on 02/07/2010 at 15:21, and is filed under General. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |