本帖最后由 zhongziso 于 2022-9-7 10:13 编辑
只需要获取到文件信息的json参数以及Authorization授权就好了,连cookie都不需要。
接口代码如下:
- <?php
- $ch = curl_init();
-
- curl_setopt($ch, CURLOPT_URL, ‘https://www.123pan.com/b/api/file/download_info’);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, "{"driveId":0,"etag":"39a604a25e4d7bbc7c640ce4ae2e0bd7","fileId":1806172,"s3keyFlag":"1812603032-0","type":0,"fileName":"videoplayback.mp4","size":60242630}");
-
- $headers = array();
- $headers[] = ‘Content-Type: application/json’;
- $headers[] = ‘Host: www.123pan.com’;
- $headers[] = ‘Origin: https://www.123pan.com’;
- $headers[] = ‘Referer: https://www.123pan.com/’;
- $headers[] = ‘User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36’;
- $headers[] = ‘Authorization: xxxxx’;
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
-
- $result = curl_exec($ch);
- if (curl_errno($ch)) {
- echo ‘Error:’ . curl_error($ch);
- }
- curl_close($ch);
- ?>
复制代码
正确执行之后,会得到这样的一个json返回结果
- {"code":0,"message":"ok","data":{"AccessKeyId":null,"SecretAccessKey":null,"SessionToken":null,"Expiration":null,"Key":"","Bucket":"","FileId":0,"Reuse":false,"Info":null,"UploadId":"","DownloadUrl":"https://download.123pan.cn/123-983/39a604a2/1812603032-0/39a604a25e4d7bbc7c640ce4ae2e0bd7?v=3u0026t=1662602379u0026s=e1062748ac0ff2d52bdbf38c1ff5aaa4u0026i=7284c7efu0026filename=videoplayback.mp4"}}
复制代码
DownloadUrl
- https://download.123pan.cn/123-983/39a604a2/1812603032-0/39a604a25e4d7bbc7c640ce4ae2e0bd7?v=3&t=1662602379&s=e1062748ac0ff2d52bdbf38c1ff5aaa4&i=7284c7ef&filename=videoplayback.mp4
复制代码
就是下载地址 他会302跳转到一个直链地址。 |