php怎么使用代码,这段 PHP 代码怎么使用?

我需要的是获取这个页面 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'));

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值