summaryrefslogtreecommitdiff
path: root/www/youtube.php
blob: 062456b333f0185bf29d3fc127a806df89fb5ee7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!Doctype html>
<body>
<center>

<?php

require("zend_init.php");	//generates the $yt object, API version 2
require("youtube_functions.php");

function getAndPrintVideoFeed($location, $yt)
{

	$videoFeed = $yt->getVideoFeed($location);
	$videoID = printVideoFeed($videoFeed);
	return $videoID;
}

function printVideoFeed($videoFeed)
{

	$res_quant = count($videoFeed);

	$video = mt_rand(1, $res_quant);

	$videoId = printVideoEntry($videoFeed[$video]);

	return $videoId;

}

function printVideoEntry($videoEntry)
{
	$videoId = $videoEntry->getVideoId();
	return  $videoId;
}



$searchstring = searchterm();

$location = $yt->newVideoQuery();
$location->setOrderBy('viewCount');
$location->setSafeSearch('none');
$location->setVideoQuery($searchstring);

$videoID = getAndPrintVideoFeed($location, $yt);



echo "Your youtube Video with the search string: <font color='green'>" . $searchstring . "</font><br> <br>";
?>

<iframe width="560" height="315" src="//www.youtube.com/embed/<? echo $videoID ?>" frameborder="0" allowfullscreen></iframe> <br><br>

<a href="youtube.php">Get another one!</a>

</center>