2022年9月最新蓝奏云直链解析API接口

最新蓝奏云直连解析API接口php代码

2022年9月最新接口,更新的规则再最下面

API接口说明

支持检测文件是否被取消

支持带密码的文件分享链接但不支持分享的文件夹

支持生成直链或直接下载

增加ios应用在线安装

解析最终直链

自动识别旧版链接替换为新版并解析

接口使用方法

url:蓝奏云外链链接

type:是否直接下载 值:down

pwd:外链密码

直接下载:

无密码:您的域名/lanzou/?url=https://www.lanzous.com/i6th9cd&type=down

有密码:您的域名/lanzou/?url=https://www.lanzous.com/i42Xxebssfg&type=down&pwd=1234

输出直链:

无密码:您的域名/lanzou/?url=https://www.lanzous.com/i6th9cd

有密码:您的域名/lanzou/?url=https://www.lanzous.com/i42Xxebssfg&pwd=1234

API接口代码

<?php
//伊亮仅为学习制作
header('Access-Control-Allow-Origin:*');
header('Content-Type:application/json; charset=utf-8');
//默认UA
$UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36';
$url = isset($_GET['url']) ? $_GET['url'] : "";
$pwd = isset($_GET['pwd']) ? $_GET['pwd'] : "";
$type = isset($_GET['type']) ? $_GET['type'] : "";
if (empty($url)) {
    die(
    json_encode(
        array(
            'code' => 400,
            'msg' => '请输入URL'
        )
        , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
    );
}
//一个简单的链接处理
$url='https://www.lanzoux.com/'.explode('.com/',$url)['1'];
$softInfo = MloocCurlGet($url);
if (strstr($softInfo, "文件取消分享了") != false) {
    die(
    json_encode(
        array(
            'code' => 400,
            'msg' => '文件取消分享了'
        )
        , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
    );
}
preg_match('~style="font-size: 30px;text-align: center;padding: 56px 0px 20px 0px;">(.*?)</div>~', $softInfo, $softName);
if(!isset($softName[1])){
preg_match('~<div class="n_box_fn".*?>(.*?)</div>~', $softInfo, $softName);
}
preg_match('~<div class="n_filesize".*?>大小:(.*?)</div>~', $softInfo, $softFilesize);
if(!isset($softName[1])){
preg_match('~var filename = '(.*?)';~', $softInfo, $softName);
}
if (strstr($softInfo, "手机Safari可在线安装") != false) {
  if(strstr($softInfo, "n_file_infos") != false){
      $ipaInfo = MloocCurlGet($url, 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1');
    preg_match('~href="(.*?)" target="_blank" class="appa"~', $ipaInfo, $ipaDownUrl);
    }else{
    preg_match('~com/(w+)~', $url, $lanzouId);
        if (!isset($lanzouId[1])) {
            die(
            json_encode(
                array(
                    'code' => 400,
                    'msg' => '解析失败,获取不到文件ID'
                )
                , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
            );
        }
        $lanzouId = $lanzouId[1];
        $ipaInfo = MloocCurlGet("https://www.lanzoux.com/tp/" . $lanzouId, 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1');
        preg_match('~href="(.*?)" id="plist"~', $ipaInfo, $ipaDownUrl);
    }
    
    $ipaDownUrl = isset($ipaDownUrl[1]) ? $ipaDownUrl[1] : "";
    if ($type != "down") {
        die(
        json_encode(
            array(
                'code' => 200,
                'msg' => '',
                'name' => isset($softName[1]) ? $softName[1] : "",
                'downUrl' => $ipaDownUrl
            )
            , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
        );
    } else {
        header("Location:$ipaDownUrl");
        die;
    }
}
if(strstr($softInfo, "function down_p(){") != false){
if(empty($pwd)){
die(
json_encode(
array(
'code' => 400,
'msg' => '请输入分享密码'
)
, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
}
preg_match("~action=(.*?)&sign=(.*?)&p='+(.*?),~", $softInfo, $segment);
$post_data = array(
"action" => $segment[1],
"sign" => $segment[2],
"p" => $pwd
);
$softInfo = MloocCurlPost($post_data, "https://www.lanzoux.com/ajaxm.php", $url);
$softName[1] = json_decode($softInfo,JSON_UNESCAPED_UNICODE)['inf'];
}else{
preg_match("~n<iframe.*?name="[sS]*?"ssrc="/(.*?)"~", $softInfo, $link);
$ifurl = "https://www.lanzoux.com/" . $link[1];
$softInfo = MloocCurlGet($ifurl);
preg_match_all("~pdownload = '(.*?)'~", $softInfo, $segment);
if(empty($segment[1][0])){
preg_match_all("~ispostdowns = '(.*?)'~", $softInfo, $segment);
}
if(empty($segment[1][0])){
preg_match_all("~'sign':'(.*?)'~", $softInfo, $segment);
}
$post_data = array(
"action" => 'downprocess',
"signs"=>"?ctdf",
"sign" => $segment[1][0],
);
$softInfo = MloocCurlPost($post_data, "https://www.lanzoux.com/ajaxm.php", $ifurl);
}
$softInfo = json_decode($softInfo, true);
if ($softInfo['zt'] != 1) {
    die(
    json_encode(
        array(
            'code' => 400,
            'msg' => $softInfo['inf']
        )
        , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
    );
}
$downUrl1 = $softInfo['dom'] . '/file/' . $softInfo['url'];
//解析最终直链地址
$downUrl2 = MloocCurlHead($downUrl1,"http://developer.store.pujirc.com",$UserAgent,"down_ip=1; expires=Sat, 16-Nov-2019 11:42:54 GMT; path=/; domain=.baidupan.com");
if($downUrl2 == ""){
$downUrl = $downUrl1;
}else{
$downUrl = $downUrl2;
}
if ($type != "down") {
    die(
    json_encode(
        array(
            'code' => 200,
            'msg' => '',
            'name' => isset($softName[1]) ? $softName[1] : "",
            'filesize' => isset($softFilesize[1]) ? $softFilesize[1] : "",
            'downUrl' => $downUrl
        )
        , JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
    );
} else {
    header("Location:$downUrl");
    die;
}
function MloocCurlGetDownUrl($url)
{
    $header = get_headers($url,1);
    if(isset($header['Location'])){
return $header['Location'];
}
return "";
}
function MloocCurlGet($url = '', $UserAgent = '')
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    if ($UserAgent != "") {
        curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
    }
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.Rand_IP(), 'CLIENT-IP:'.Rand_IP()));
    #关闭SSL
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    #返回数据不直接显示
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}
function MloocCurlPost($post_data = '', $url = '', $ifurl = '', $UserAgent = '')
{
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
    if ($ifurl != '') {
        curl_setopt($curl, CURLOPT_REFERER, $ifurl);
    }
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.Rand_IP(), 'CLIENT-IP:'.Rand_IP()));
    #关闭SSL
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    #返回数据不直接显示
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    $response = curl_exec($curl);
    curl_close($curl);
    return $response;
}
//直链解析函数
function MloocCurlHead($url,$guise,$UserAgent,$cookie){
$headers = array(
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding: gzip, deflate',
'Accept-Language: zh-CN,zh;q=0.9',
'Cache-Control: no-cache',
'Connection: keep-alive',
'Pragma: no-cache',
'Upgrade-Insecure-Requests: 1',
'User-Agent: '.$UserAgent
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headers);
curl_setopt($curl, CURLOPT_REFERER, $guise);
curl_setopt($curl, CURLOPT_COOKIE , $cookie);
curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
curl_setopt($curl, CURLOPT_NOBODY, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLINFO_HEADER_OUT, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$data = curl_exec($curl);
$url=curl_getinfo($curl);
curl_close($curl);
return $url["redirect_url"];
}
function Rand_IP(){
    $ip2id = round(rand(600000, 2550000) / 10000);
    $ip3id = round(rand(600000, 2550000) / 10000);
    $ip4id = round(rand(600000, 2550000) / 10000);
    $arr_1 = array("218","218","66","66","218","218","60","60","202","204","66","66","66","59","61","60","222","221","66","59","60","60","66","218","218","62","63","64","66","66","122","211");
    $randarr= mt_rand(0,count($arr_1)-1);
    $ip1id = $arr_1[$randarr];
    return $ip1id.".".$ip2id.".".$ip3id.".".$ip4id;
}
?>

 

2022年9月之后蓝揍直连解析规则更新:

若你不会使用,请右侧联系客服,帮你搭建,红包随你心意给~

<?php
//2022年9月最新规则   更新如下:
function getSubstr($str, $leftStr, $rightStr)
{
$left = strpos($str, $leftStr);
//echo '左边:'.$left;
$right = strpos($str, $rightStr,$left);
//echo '<br>右边:'.$right;
if($left < 0 or $right < $left) return '';
return substr($str, $left + strlen($leftStr), $right-$left-strlen($leftStr));
}
//构造http请求
function http_get($url){
$oCurl = curl_init();
$user_agent = "User-Agent: 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";
if(stripos($url,"https://")!==FALSE){
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($oCurl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($oCurl, CURLOPT_SSLVERSION, 1); //CURL_SSLVERSION_TLSv1
}
curl_setopt($oCurl, CURLOPT_USERAGENT,$user_agent);
curl_setopt($oCurl, CURLOPT_URL, $url);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1 );
$sContent = curl_exec($oCurl);
$aStatus = curl_getinfo($oCurl);
curl_close($oCurl);
if(intval($aStatus["http_code"])==200){
return $sContent;
}else{
return false;
}
}
if(isset($_GET['id'])){
$web = http_get(str_replace("com/","com/tp/",'https://huaqu.lanzouw.com/'.$_GET['id']));
$domianload = getSubstr($web,"cppat = '","';");
$downloads = getSubstr($web,"cppat + '","}");
$url = $domianload.$downloads;
//echo $url;
//直接下载使用下面这句
header("Location: ".$url);
}
?>

上面的huaqu.lanzouw.com,换成你的个性域名,能提高解析速度~

给TA打赏
共{{data.count}}人
人已打赏
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索