//本源码可以快速的在自己网站就可以建立离线下载任务,比如有人上传文件到懒人博客,直接就可以调用本源码保存懒人博客的百度云盘了。 header("content-Type: text/html; charset=utf-8"); ignore_user_abort(true); //设置关掉浏览器继续执行 set_time_limit(0); //设置超时 $do = isset($_GET['do']) ? $_GET['do'] : ''; $durl = isset($_GET['durl']) ? $_GET['durl'] : ''; $home = isset($_GET['home']) ? $_GET['home'] : ''; $home = urlencode($home); if(!$do) { //home 请勿修改 //durl 为要上传的文件地址(外网线上文件地址: 如: http://cheshi.dahuzhi.com/new.txt) echo <<<html <form method="get" action=""/> 地址:<input type="text" value="http://cheshi.dahuzhi.com/bb.zip" name="durl"/> <select name='home' id='questionid_LJesw' > <option value='游戏(apk)'>游戏(apk)</option> <option value='游戏(exe)'>游戏(exe)</option> <option value='游戏(rar)'>游戏(rar)</option> <option value='游戏(zip)'>游戏(zip)</option> <option value='源码(php)'>源码(php)</option> <option value='源码(zip)'>源码(zip)</option> <option value='源码(rar)'>源码(rar)</option> <option value='软件(apk)'>软件(apk)</option> <option value='软件(exe)'>软件(exe)</option> <option value='软件(rar)'>软件(rar)</option> <option value='软件(zip)'>软件(zip)</option> <option value='其它(txt)'>其它(txt)</option> <option value='其它(zip)'>其它(zip)</option> <option value='其它(rar)'>其它(rar)</option> <option value='书籍(txt)'>书籍(txt)</option> <option value='书籍(zip)'>书籍(zip)</option> <option value='书籍(rar)'>书籍(rar)</option> </select> <input type="submit" name="do" value="ok"/> </form> html; } else { //请勿修改 date_default_timezone_set("PRC"); $url = 'http://pan.baidu.com/rest/2.0/services/cloud_dl?devuid=510931010517968&clienttype=1&channel=android_2.3.7_BestsonnyT961_bd-netdisk_1001528c&version=5.2.0&logid=MTQwNzQ5Njc4MDU1MSwxOTIuMTY4LjEuNSw2NjMxNzA&cuid=7EF0AE3D7224DE4AD6D9C41044DA31BA%7C510931010517968'; $post = "method=add_task&app_id=250528&file_sha1=&save_path=/{$home}&source_url={$durl}&source_path=&type=0&rate_limit=0&timeout=0&callback=&selected_idx="; $_Headers = array("USER_AGENT" => "netdisk;5.2.0;BestsonnyT961;android-android;2.3.7"); /*************需要修改地方***************/ //请安装百度云客户端,然后用软件抓包工具把本地上传时候的 BDUSS 的 cookie 抓下来放在此 //(我直接提取的百度云客户端的cookie,至今未失效。你也可以提取网页版的bduss的cookie) $cookie = "你自己的bduss的cookie"; // 模拟上传百度云 $l = Get_Web_Contents($url, "POST", $post, $cookie, array(), 30, $_Headers); // var_dump($l); // die; if($l && isset($l['Body'])) { $json = json_decode($l['Body'],true); if($r = $json[task_id]) { echo "转存成功,任务id:".$r; } else { echo "转存失败,原因:".$json[error_msg]; } } } function Get_Web_Contents($_Get_Url, $_Method = "GET", $_Form_Data = "", $_Cookie = "", $_Proxy = array("Proxy" => ""), $_Time_Out = 30, $_Headers = array()){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $_Get_Url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $_Time_Out); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); if(isset($_Proxy["Proxy"])){ curl_setopt($ch, CURLOPT_PROXY, $_Proxy["Proxy"]); if(isset($_Proxy["UserNmae"]) and isset($_Proxy["PassWord"])){ curl_setopt($ch, CURLOPT_PROXYUSERPWD, $_Proxy["UserNmae"].":".$_Proxy["PassWord"]); } } if(strtoupper($_Method) == "POST"){ curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $_Form_Data); } if(strlen($_Cookie)){ curl_setopt($ch, CURLOPT_COOKIE, $_Cookie); } if(isset($_Headers)){ if(isset($_Headers['User-Agent'])){ curl_setopt($ch, CURLOPT_USERAGENT, $_Headers['User-Agent']); } curl_setopt($ch, CURLOPT_HTTPHEADER, $_Headers); } @$html = curl_exec($ch); if ($html === False) { $ret["Error"] = curl_error($ch); return $ret; } $ret["Info"] = curl_getinfo($ch); curl_close($ch); $_wz = strpos($html,"rnrn"); $ret["Header"] = substr($html,0,$_wz); if(preg_match_all("/set-cookie:s?(.*?=.*?);/i", $ret["Header"], $cookie)){ $cookie = $cookie[1]; } $ret["Cookies"] = ""; foreach ($cookie as $value){ if(!is_array($value)){ $ret["Cookies"].= $value."; "; } } $ret["Cookies"] = substr($ret["Cookies"],0,-1); $ret["Body"] = substr($html,$_wz+4); return $ret; }
Comments : 0