火山无水印最新API短链接版

shmily 568 百度已收录 0
[aru_1]火山无疑在各大短视频里面最稳定的,但是以前的已经失效。由于自身比较懒,于是百度之后又无果,那么还是自己动手解决吧,虽然碰到一些难题,最终还是胜利了。
经过深思熟虑之后,最终还是分享出来让大家互相学习交流。

注:这次的API中加入腾讯短连接,这也是脑洞大开吧。

<?php
/**
* Name:火山短视频
*/
header('Access-Control-Allow-Origin:*');
header('Content-Type:text/json;charset=utf8');
//请求
$url = @$_GET['url'];
if (strstr($url,"huoshan.com")) {
//获取301跳转真实地址       
function getrealurl($url){ $header = get_headers($url,1);
if (strpos($header[0],'301') || strpos($header[0],'302'))
{if(is_array($header['Location'])) {return $header['Location'][count($header['Location'])-1];
}else{return $header['Location'];}}else{return $url;}};
$url = getrealurl($url);
//模拟苹果手机访问
$UserAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1';
// 截取ID
function GetBetween($content,$start,$end) {
$r = explode($start, $content);
if (isset($r[1])) {
$r = explode($end, $r[1]);
return $r[0];
}
return '';
}
//一次获取ID
$b = '?item_id=';
$c = '&tag=0';
$id = GetBetween($url,$b,$c);
$json = myCurl('https://share.huoshan.com/api/item/info?item_id='.$id);
$Array = json_decode($json,true);
$video = $Array["data"]["item_info"]["url"];
$image = $Array["data"]["item_info"]["cover"];
//二次获取ID
$d = '?video_id=';
$e = '&line=0';
$video_id = GetBetween($video,$d,$e);
$videourl = myCurl('https://api-hl.huoshan.com/hotsoon/item/video/_playback/?video_id='.$video_id);
$d = 'href="';
$e = '">';
$vip = GetBetween($videourl,$d,$e);
//状态码判断
if($vip==""){
        $status = 202;
}else{
        $status= 200;
}
//腾讯短网址
$tx = myCurl('http://sa.sogou.com/gettiny?url='.$vip);
//数组
$api = array('code'=>$status,'video'=>$tx,'image'=>$image);
//数组输出
echo json_encode($api,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
}
//curl模拟get请求
function myCurl($one, $two = '', $three = ''){
        $ch = curl_init();
        $ip = mt_rand(11, 191) . "." . mt_rand(0, 240) . "." . mt_rand(1, 240) . "." . mt_rand(1, 240);
        $UserAgent='User-agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11';
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));  //构造IP
        curl_setopt($ch, CURLOPT_USERAGENT, $UserAgent); // UA
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // 超时时间:30s
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
        curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
        if (!empty($three)) {
                curl_setopt($ch, CURLOPT_REFERER, $three);
        }
        if (!empty($two)) {
                curl_setopt($ch, CURLOPT_POST, 1);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $two);
        }
        curl_setopt($ch, CURLOPT_URL, $one);
        curl_setopt($ch, CURLOPT_ENCODING, "gzip");
        $content = curl_exec($ch);
        curl_close($ch);
        return $content;
}
?>

发表评论 取消回复
表情 代码

分享