verifyPwd():'; + var_dump($result); + echo ''; + } if ($result["errno"] === 0) return $result["randsk"]; else return 1; } @@ -158,10 +161,22 @@ function getSign(string $surl, $randsk) "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36", "Cookie: BDUSS=" . BDUSS . ";STOKEN=" . STOKEN . ";BDCLND=" . $randsk . ";" ); - // if (preg_match('/yunData.setData\((\{.*?\})\);/', get($url, $header), $matches)) return json_decode($matches[1], true); //如果不修改这里,则要修改配置文件ini - if (preg_match('/yunData.setData\((\{.*?\})\);/', get($url, $header), $matches)) return json_decode($matches[1], true, 512, JSON_BIGINT_AS_STRING); - else return 1; + $result = get($url, $header); + if (preg_match('/yunData.setData\((\{.*?\})\);/', $result, $matches)) { + $result = json_decode($matches[1], true, 512, JSON_BIGINT_AS_STRING); + if (DEBUG) { + echo '
getSign():'; + var_dump($result); + echo ''; + } + return $result; + } else { + if (DEBUG) { + echo '
getSign():no match'; + } + return 1; + } } function FileList($sign) { @@ -176,32 +191,42 @@ function GetDir(string $dir, string $randsk, string $shareid, string $uk) "Cookie: BDUSS=" . BDUSS . ";STOKEN=" . STOKEN . ";BDCLND=" . $randsk . ";", "Referer: https://pan.baidu.com/disk/home" ); - return json_decode(get($url, $header), true); + $result = json_decode(get($url, $header), true); + if (DEBUG) { + echo '
GetDir():'; + var_dump($result); + echo ''; + } + return $result; } function FileInfo(string $filename, float $size, string $md5, int $server_ctime) { // 输出 HTML 字符串 return '
文件名:' . $filename . '
文件大小:' . formatSize($size) . '
文件MD5:' . $md5 . '
上传时间:' . date("Y年m月d日 H:i:s", $server_ctime) . '
'; } -function getDlink(string $fs_id, string $timestamp, string $sign, string $randsk, string $share_id, string $uk, string $bdstoken,bool $isnoualink) +function getDlink(string $fs_id, string $timestamp, string $sign, string $randsk, string $share_id, string $uk, string $bdstoken, bool $isnoualink, int $app_id = 250528) { // 获取下载链接 - $app_id = 250528; - //推荐应用ID:498065、309847、778750、250528(官方)、265486、266719; - - if($isnoualink){ - $url = 'https://pan.baidu.com/api/sharedownload?app_id=' . $app_id . '&channel=chunlei&clienttype=0&sign=' . $sign . '×tamp=' . $timestamp . '&web=1&bdstoken='.$bdstoken;//获取直链 50MB以内 - }else{ - $url = 'https://pan.baidu.com/api/sharedownload?app_id=' . $app_id . '&channel=chunlei&clienttype=12&sign=' . $sign . '×tamp=' . $timestamp . '&web=1';//获取下载链接 + + if ($isnoualink) { + $url = 'https://pan.baidu.com/api/sharedownload?app_id=' . $app_id . '&channel=chunlei&clienttype=0&sign=' . $sign . '×tamp=' . $timestamp . '&web=1&bdstoken=' . $bdstoken; //获取直链 50MB以内 + } else { + $url = 'https://pan.baidu.com/api/sharedownload?app_id=' . $app_id . '&channel=chunlei&clienttype=12&sign=' . $sign . '×tamp=' . $timestamp . '&web=1'; //获取下载链接 } - + $data = "encrypt=0" . "&extra=" . urlencode('{"sekey":"' . urldecode($randsk) . '"}') . "&fid_list=[$fs_id]" . "&primaryid=$share_id" . "&uk=$uk" . "&product=share&type=nolimit"; $header = array( "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36", "Cookie: BDUSS=" . BDUSS . ";STOKEN=" . STOKEN . ";BDCLND=" . $randsk . ";", "Referer: https://pan.baidu.com/disk/home" ); - return json_decode(post($url, $data, $header), true); - + $result = json_decode(post($url, $data, $header), true); + if (DEBUG) { + echo 'getDlink():'; + var_dump($result); + echo ''; + } + return $result; + //没有 referer 就 112 ,然后没有 sekey 参数就 118 -20出现验证码 // 参数 类型 描述 // list json array 文件信息列表 @@ -218,9 +243,33 @@ function getDlink(string $fs_id, string $timestamp, string $sign, string $randsk // list[0]["width"] int 图片宽度 // list[0]["date_taken"] int 图片拍摄时间 } -function dl_error(string $title, string $content) +function dl_error(string $title, string $content, bool $jumptip = false) { echo '
' . $content . '
' . $content;
+ if ($jumptip) {
+ echo '
请打开调试模式,并将错误信息复制提交issue到github项目。';
+ }
+ echo '
get_BDCLND():'; + var_dump($matches[1]); + echo ''; + } + return $matches[1]; + } else { + if (DEBUG) { + echo '
get_BDCLND():'; + var_dump($header); + echo ''; + } + return ''; + } +} \ No newline at end of file diff --git a/index.php b/index.php index ff2d2642..f2c1bee5 100644 --- a/index.php +++ b/index.php @@ -12,7 +12,7 @@ * * 此项目 GitHub 地址:https://github.com/yuantuo666/baiduwp-php * - * @version 1.4.1 + * @version 1.4.2 * * @author Yuan_Tuo
提取码错误或文件失效!
已获取到文件,但未能获取到下载链接!
请检查你是否在 config.php
中配置 SVIP 账号的 BDUSS 和 STOKEN!
未配置或配置了普通账号的均会导致失败!必须要 SVIP 账号!
' . FileInfo($filename, $size, $md5, $server_ctime) . '- - 直链(无需设置UA) -
'; - } - - ?> - - -- 下载链接(不安全) - 下载链接(需设置UA,8小时有效) -
-- 推送到Aria2 -
-