Ifeng.class.php
1.63 KB
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
<?php
class Util_Video_Api_Ifeng extends Util_Video_Api
{
private $xmlurl = 'http://v.ifeng.com/video_info_new/{id_1}/{id_2}/{id}.xml';
public function getData($url)
{
$id = $this->getid($url);
$id_2 = substr($id, strlen($id) - 2, 2);
$id_1 = substr($id_2, 0, 1);
$infourl = str_ireplace("{id_1}", $id_1, $this->xmlurl);
$infourl = str_ireplace("{id_2}", $id_2, $infourl);
$infourl = str_ireplace("{id}", $id, $infourl);
$infodat = Util_Video_ApiConnect::get($infourl);
if(!function_exists("simplexml_load_file"))
{
throw new Util_Video_ApiException('simplexml_load_file 不存在');
}
$infodat = @simplexml_load_string($infodat);
if($infodat == null)
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($this->id);
//$dataobj->swf = (string) $infodat->item['VideoPlayUrl'];
$dataobj->swf = 'http://v.ifeng.com/include/exterior.swf?AutoPlay=false&guid='.$this->id;
$dataobj->thumb = (string) $infodat->item['SmallPosterUrl'];
$dataobj->time = (string) $infodat->item['CreateDate'];
$dataobj->title = (string) $infodat->item['Name'];
$dataobj->source = '来自于ifeng.com';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(!preg_match("/^http:\/\/.*/si", $url))
{
$id = $url;
}
$id = str_replace(array('index.shtml#','.shtml','#'), '', substr(strrchr($url, '/'), 1));
$this->id = $id;
return $id;
}
}
?>