2022年蓝奏云PHP解析API接口源代码
2022年蓝奏云PHP解析API接口源代码是一个用于获取蓝奏云文件列表的PHP程序。它通过调用蓝奏云提供的API接口,实现对用户上传的文件进行解析和展示。用户可以通过该程序快速查看自己上传的文件,方便管理和下载。同时,该程序还支持搜索功能,可以根据文件名、文件类型等条件进行筛选,提高查找效率。此外,该程序还具备一定的安全性,可以防止恶意攻击和滥用。总之,2022年蓝奏云PHP解析API接口源代码是一个非常实用的工具,可以帮助用户更好地管理自己的蓝奏云文件。
蓝奏云解析API代码
<?phpheader('Content-Type:application/json;charset=utf-8');//默认UA$UserAgent='Mozilla/5.0(WindowsNT10.0;Win64;x64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/72.0.3626.121Safari/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'=>'请输入需要解析的蓝奏云网盘地址'),480));}//一个简单的链接处理$url='https://www.lanzoux.com/'.explode('.com/',$url)['1'];$softInfo=MloocCurlGet($url);if(strstr($softInfo,"文件取消分享了")!=false){die(json_encode(array('code'=>400,'msg'=>'文件取消分享了'),480));}preg_match('~style="font-size:30px;text-align:center;padding:56px0px20px0px;">(.*?)</div>~',$softInfo,$softName);if(!isset($softName[1])){preg_match('~<divclass="n_box_fn".*?>(.*?)</div>~',$softInfo,$softName);}preg_match('/<metaname="description"content="(.*?)"/',$softInfo,$softFilesize);if(!isset($softName[1])){preg_match('~varfilename='(.*?)';~',$softInfo,$softName);}if(strstr($softInfo,"手机Safari可在线安装")!=false){if(strstr($softInfo,"n_file_infos")!=false){$ipaInfo=MloocCurlGet($url,'Mozilla/5.0(iPhone;CPUiPhoneOS10_3_1likeMacOSX)AppleWebKit/603.1.30(KHTML,likeGecko)Version/10.0Mobile/14E304Safari/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'),480));}$lanzouId=$lanzouId[1];$ipaInfo=MloocCurlGet("https://www.lanzoux.com/tp/".$lanzouId,'Mozilla/5.0(iPhone;CPUiPhoneOS10_3_1likeMacOSX)AppleWebKit/603.1.30(KHTML,likeGecko)Version/10.0Mobile/14E304Safari/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]:"",'filesize'=>isset($softFilesize[1])?str_replace(['文件大小:','|'],'',$softFilesize[1]):"",'downurl'=>$ipaDownUrl,'text'=>['msg'=>'此接口只支持蓝奏云网盘解析','copyright'=>'苏晓晴2022.6.12基于源代码重构','time'=>'当前解析时间为:'.date('Y-m-dH:i:s',time())]),480));}else{header("Location:$ipaDownUrl");die;}}if(strstr($softInfo,"functiondown_p(){")!=false){if(empty($pwd)){die(json_encode(array('code'=>400,'msg'=>'请输入分享密码'),480));}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']),480));}$downUrl1=$softInfo['dom'].'/file/'.$softInfo['url'];//解析最终直链地址$downUrl2=MloocCurlHead($downUrl1,"http://developer.store.pujirc.com",$UserAgent,"down_ip=1;expires=Sat,16-Nov-201911:42:54GMT;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])?str_replace(['文件大小:','|'],'',$softFilesize[1]):"",'downurl'=>$downUrl,'text'=>['msg'=>'此接口只支持蓝奏云网盘解析','copyright'=>'苏晓晴2022.6.12基于源代码重构','time'=>'当前解析时间为:'.date('Y-m-dH:i:s',time())]),480));}else{header("Location:$downUrl");die;}functionMloocCurlGetDownUrl($url){$header=get_headers($url,1);if(isset($header['Location'])){return$header['Location'];}return"";}functionMloocCurlGet($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()));#关闭SSLcurl_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;}functionMloocCurlPost($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()));#关闭SSLcurl_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;}//直链解析函数functionMloocCurlHead($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"];}functionRand_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;}?>
使用方法
1、将文件上传到网站目录
2、然后浏览器地址栏输入/lanzou.php?url=网盘地址
GET方法可选参数
pwd(网盘地址密码)
type(down直接跳转至下载直链,留空则JSON格式输出)
相关专题