class BaiduYunTransfer headers = User-Agent Mozilla50 Windows NT 100; Win64; x64 AppleWebKit53736 KHTML like Gecko Chrome8304103116 Safari53736 Referer panbaiducom universal_error
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36',
'Referer' => 'pan.baidu.com'
);
private $universal_error_code = array(
'2' => '参数错误。检查必填字段;get/post 参数位置',
'-6' => '身份验证失败。access_token 是否有效;部分接口需要申请对应的网盘权限',
'31034' => '命中接口频控。核对频控规则;稍后再试;申请单独频控规则',
'42000' => '访问过于频繁',
'42001' => 'rand校验失败',
'42999' => '功能下线',
'9100' => '一级封禁',
'9200' => '二级封禁',
'9300' => '三级封禁',
'9400' => '四级封禁',
'9500' => '五级封禁'
);
public function __construct($api_key, $secret_key, $share_link, $password, $folderpath, $new_name_list) {
$this->api_key = $api_key;
$this->secret_key = $secret_key;
$this->share_link = $share_link;
$this->password = $password;
$this->folderpath = $folderpath;
$this->new_name_list = $new_name_list;
if ($this->init_token() && $this->get_surl() && $this->get_sekey() && $this->get_shareid_and_uk_and_fsidlist()) {
$this->mkdir();
if ($this->file_transfer()) {
if (!empty($this->new_name_list)) {
$this->rename();
}
echo '本次转存任务结束';
}
}
}
private function init_token() {
// Implementation of init_token method
}
private function get_surl() {
// Implementation of get_surl method
}
private function get_sekey() {
// Implementation of get_sekey method
}
private function get_shareid_and_uk_and_fsidlist() {
// Implementation of get_shareid_and_uk_and_fsidlist method
}
private function mkdir() {
// Implementation of mkdir method
}
private function file_transfer() {
// Implementation of file_transfer method
}
private function rename() {
// Implementation of rename method
}
}
$api_key = 'your_api_key';
$secret_key = 'your_secret_key';
$share_link = 'your_share_link';
$password = 'your_password';
$folderpath = 'your_folder_path';
$new_name_list = array(); // Array of new names
$transfer = new BaiduYunTransfer($api_key, $secret_key, $share_link, $password, $folderpath, $new_name_list);
?
原文地址: http://www.cveoy.top/t/topic/hWEi 著作权归作者所有。请勿转载和采集!