QQ空间视频解析源码
- <?php
- //1006_06e29b9e38374b909e5192dfea48a83c
- function get_qzone_video($picKey){
- preg_match(‘#p_skey=(.*);#iU’,COOKIE_QQ,$p_skey);
- preg_match(‘#uin=(.*);#iU’,COOKIE_QQ,$uin);
- $tk = g_tk($p_skey[1]);
- $hostUin = str_replace(“o0″,””,$uin[1]);
- $api = “https://h5.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/video_get_data?g_tk={$tk}&picKey={$picKey}&number=1&hostUin={$hostUin}&getMethod=3”;
- $content = curl($api,COOKIE_QQ);
- $json = str_replace(“);”,””,str_replace(“_Callback(“,””,$content));
- $data = json_decode($json,true);
- if($data[“code”]==0){
- foreach ($data[“data”][“photos”] as $key => $value) {
- $fkey = $value[“picKey”];
- if($fkey == $picKey){
- $vurl = $value[“url”];
- $videoinfo[“video”][“file”] = $vurl;
- $videoinfo[“video”][“type”] = “video/mp4”;
- return $videoinfo;
- }
- }
- }else{
- return GlobalBase::get_unknown_video();
- }
- }
- function get_qzone_all_video(){
- preg_match(‘#p_skey=(.*);#iU’,COOKIE_QQ,$p_skey);
- preg_match(‘#uin=(.*);#iU’,COOKIE_QQ,$uin);
- $tk = g_tk($p_skey[1]);
- $hostUin = str_replace(“o0″,””,$uin[1]);
- $api = “https://h5.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/video_get_data?g_tk={$tk}&hostUin={$hostUin}&appid=4&getMethod=2&count=2000”;
- $content = curl($api,COOKIE_QQ);
- $json = str_replace(“);”,””,str_replace(“_Callback(“,””,$content));
- $data = json_decode($json,true);
- if($data[“code”]==0){
- foreach ($data[“data”][“Videos”] as $key => $value) {
- $videos[$key][“vid”] = $value[“vid”];
- $videos[$key][“pic”] = $value[“pre”];
- $videos[$key][“title”] = $value[“title”];
- $videos[$key][“url”] = $value[“url”];
- }
- }
- return $videos;
- }
- function curl($url,$cookie=””)
- {
- $params[“ua”] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36”;
- $params[“cookie”] = $cookie;
- $params[“proxy”] = PROXY;//代理地址
- return GlobalBase::curl($url,$params);
- }
- function g_tk($data) {
- $t = 5381;
- $chars = str_split($data);
- for ($n = 0,$r = strlen($data); $n < $r; ++$n) {
- $t += intval32($t << 5) + ord($chars[$n]);
- }
- return $t & 2147483647;
- }
- function intval32($num) {
- $num = $num & 0xffffffff;
- $p = $num>>31;
- if($p==1) {
- $num = $num-1;
- $num = ~$num;
- $num = $num & 0xffffffff;
- return $num * -1;
- } else {
- return $num;
- }
- }
- ?>