Thinkphp实现腾讯视频解析

158 阅读1分钟

$data['upurl']=htmlspecialchars_decode($data['video']);
if(strpos($data['video'],'v.qq.com')!==false){
				$temp=file_get_contents($data['video']);
				preg_match('/"vid":"(.*?)"/i',$temp,$m);
				$vid=$m[1];
				$url='http://vv.video.qq.com/getinfo?vids='.$vid.'&platform=101001&charge=0&otype=json';
				$result=file_get_contents($url);
				$result=str_replace('QZOutputJson=','',$result);
				$result=str_replace('};','}',$result);
				$result=json_decode($result,true);
				$endres=$result['vl']['vi'][0]['ul']['ui'][0]['url'] . $result['vl']['vi'][0]['fn'] . '?vkey=' . $result['vl']['vi'][0]['fvkey'];
				$data['upurl']=$endres;
				// dump($endres);exit;
}

此方法可以去掉自带的视频广告,可以替换成自己的”视频前贴广告“实现收益

该代码请放在API中使用,根据自己项目的需要修改即可实现。

小程序体验

gh_19c664e55992_258.jpg