blob: 9d6ebac7225308b9bf03f8e82abf673c41fff82e (
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
|
<?php
function failure($reason){
header("HTTP/1.1 404 Not Found");
echo $reason;
exit;
}
function get_all_yt_data($id){
$data = file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$id."");
$data = preg_replace("/yt:statistics/", "ytstatistics", $data);
$data = preg_replace("/media:group/", "mediagroup", $data);
$data = preg_replace("/media:description/", "mediadescription", $data);
$data = preg_replace("/gd:rating/", "gdrating", $data);
$xmldata = simplexml_load_string($data);
$title = $xmldata->title[0];
$viewCount = $xmldata->ytstatistics["viewCount"];
$author = $xmldata->author->name[0];
$desc = $xmldata->mediagroup->mediadescription[0];
$date = $xmldata->published[0];
$rate = $xmldata->gdrating["average"];
$res["title"] = $title;
$res["viewCount"] = $viewCount;
$res["author"] = $author;
$res["desc"] = $desc;
$res["date"] = $date;
$res["rate"] = $rate;
return $res;
}
function get_yt_title($id){
$data = file_get_contents("https://gdata.youtube.com/feeds/api/videos/".$id."");
$xmldata = simplexml_load_string($data);
$title = $xmldata->title[0];
return $title;
}
|