我需要的是获取这个页面
http://fanxing.kugou.com/mvplay/807720485470212096
的 MP4 视频地址;别人给出了下面的 PHP 代码,我保存在 PHP 空间 打开
没反应,怎么回事?
代码如下:
function getVideUrl($requetUrl) {
preg_match('@http://fanxing.kugou.com/mvplay/(\d+)#?(\d+)*@', $requetUrl, $match);
// var_dump($match);exit;
if (empty($match)) {
return -1;
}
$videoId = isset($match[2]) ? $match[2] : $match[1];
$t = substr(microtime(1)*1000, 0, 13);
$content = file_get_contents('http://fanxing.kugou.com/Services.php?act=Video.OfflineVideoService&mtd=getVideoAllInfoByVideoId&args=['.$videoId.',0,0]&_='.$t.'&jsonpcallback=jsonp2');
$content = str_replace(['jsonp2(', ')'], '', $content);
$content = json_decode($content, 1);
if (empty($content['data']['videoInfo']['hashValue'])) {
return -2;
}
$hashValue = $content['data']['videoInfo']['hashValue'];
$g = "callbackcallbackformatjsonphash" .$hashValue. "pid6kugou_video";
$url = "http://tracker.v.kugou.com/video/query?pid=6&hash=" . $hashValue . "&sign=" . md5($g) . "&format=jsonp&callback=callback";
$content = file_get_contents($url);
$content = str_replace(['callback(', ')'], '', $content);
$content = json_decode($content, 1);
if (empty($content['data']['url'])) {
return -3;
}
return $content['data']['url'];
}
var_dump(getVideUrl('http://fanxing.kugou.com/mvplay/807720485470212096'));