1. 腾讯视频的VIDS获取
如:https://v.qq.com/x/page/d0852jx84od.html
vid 即d0852jx84od
2.访问getinfo
function get_url($url)
{
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //不验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$result=curl_exec($ch);
$code=curl_getinfo($ch,CURLINFO_HTTP_CODE);
if($code!='404' && $result)
{
return $result;
}
curl_close($ch);
}
/**
* 获取腾讯视频高清地址
*/
function get_tc_video($vids)
{
if(empty($vids)) {
return false;
}
$res = get_url('http://vv.video.qq.com/getinfo?otype=json&platform=11001&vid='.$vids);
if(empty($res)){
return false;
}
$key_res = get_url('http://vv.video.qq.com/getkey?format=2&otype=json&vt=150&vid='.$vids.'&ran=0\%2E9477521511726081\\&charge=0&filename='.$vids.'.mp4&platform=11');
if(empty($key_res)){
return false;
}
$res = mb_substr(mb_strcut($res, 13),0,-1);
$res = json_decode($res, true);
$u = $res['vl']['vi'][0];
$p0 = $u['ul']['ui'][0]['url'];
$p1 = $vids.'.mp4';
$key_arr = explode("=",$key_res);
$new_key = rtrim($key_arr[1],";");
$new_key_arr = json_decode($new_key,true);
$p2 = $new_key_arr['key'];
return $p0.$p1.'?vkey='.$p2;
}
//获取地址
function get_tc_video($vids)
{
if(empty($vid)) { return false; }
$res = get_url('http://vv.video.qq.com/getinfo?otype=json&platform=11001&vid='.$vids);
$res = mb_substr(mb_strcut($res, 13),0,-1);
$res = json_decode($res, true);
$u = $res['vl']['vi'][0];
$p0 = $u['ul']['ui'][0]['url'];
$p1 = $u['fn'];
$p2 = $u['fvkey'];
return $p0.$p1.'?vkey='.$p2;
}
$vid = 'd0852jx84od';
$video_url = get_tc_video($vid);
echo $video_url;