/
example.php
86 lines (77 loc) · 2.59 KB
/
example.php
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!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" xml:lang="en" lang="en">
<head>
<title>Listing most viewed videos</title>
<style type="text/css">
div.item {
border-top: solid black 1px;
margin: 10px;
padding: 2px;
width: auto;
padding-bottom: 20px;
}
.item p{
display: block;
overflow: hidden;
}
span.thumbnail {
float: left;
margin-right: 20px;
padding: 2px;
border: solid silver 1px;
font-size: x-small;
text-align: center;
}
span.attr {
font-weight: bolder;
}
span.title {
font-weight: bolder;
font-size: x-large;
}
img {
border: 0px;
}
a {
color: brown;
text-decoration: none;
}
</style>
</head>
<body>
<?php
require_once dirname(__FILE__).'/youtube.lib.php';
$yt = new Youtube(array('user' => 'google', 'limit' => 5));
//$data = $yt->apiCall();
//$videos = $yt->getVideosFromData($data);
//$videos = $yt->getUserSubscriptions();
//$videos = $yt->getStandardFeed(array('limit' => 4, 'feed' => 'most_viewed', 'time' => 'this_month'));
//$yt->setOptions(array("time"=>"this_month", 'limit' => 4));
//$videos = $yt->getStandardFeed("most_viewed");
$videos = $yt->searchForVideos( array('search' => 'seat race crash', 'limit' => 5) );
//$videos = $yt->searchForVideos( "seat race crash" );
//$video = $yt->getSingleVideo("dogM4Wu51tc");
foreach ($videos as $i => $video) {
$embed = $yt->getEmbedHTML($video); ?>
<div class="item">
<span class="title">
<a href="<?php echo $video['link']; ?>"><?php echo $video['title']; ?></a>
</span>
<p><?php echo $video['description']; ?></p>
<p>
<span class="thumbnail">
<?php echo $embed; ?>
</span>
<span class="attr">By:</span> <?php echo $video['author']['name']; ?> <br/>
<span class="attr">Duration:</span> <?php echo $video['duration']; ?> min. <br/>
<span class="attr">Views:</span> <?php echo $video['views']; ?> <br/>
<span class="attr">Rating:</span> <?php echo $video['rating']; ?>
</p>
</div>
<?php
}
?>
</body>
</html>