准备文件
1、ck.txt
2、sign.php
文件代码
<?php
$cookie = trim(file_get_contents(__DIR__ . '/ck.txt'));
if (empty($cookie)) {
echo "无法读取cookie。请确保ck.txt文件存在且包含有效的cookie。\n";
exit();
}
$userUrl = "https://pan.quark.cn/account/info";
$context = stream_context_create([
'http' => [
'header' => "Cookie: $cookie\r\n"
]
]);
$userInfoResponse = file_get_contents($userUrl, false, $context);
$userInfo = json_decode($userInfoResponse, true)["data"] ?? null;
if (!$userInfo || !isset($userInfo["nickname"])) {
echo "登录失败,cookie错误。\n";
exit();
}
echo "登录成功。\n";
$stateUrl = "https://drive-m.quark.cn/1/clouddrive/capacity/growth/info?pr=ucpro&fr=pc&uc_param_str=";
$stateResponse = file_get_contents($stateUrl, false, $context);
$stateData = json_decode($stateResponse, true);
$sign = $stateData["data"]["cap_sign"] ?? null;
if ($sign && isset($sign["sign_daily"]) && $sign["sign_daily"]) {
$number = ($sign["sign_daily_reward"] ?? 0) / (1024 * 1024);
$progress = (isset($sign["sign_progress"], $sign["sign_target"])) ? bcdiv($sign["sign_progress"], $sign["sign_target"], 4) * 100 : 0;
echo "今日已签到获取{$number}MB,进度{$progress}%\n";
exit();
}
$signUrl = "https://drive-m.quark.cn/1/clouddrive/capacity/growth/sign?pr=ucpro&fr=pc&uc_param_str=";
$params = [
"sign_cyclic" => true
];
$headers = [
"Content-Type: application/json",
"Cookie: $cookie"
];
$options = [
'http' => [
'header' => implode("\r\n", $headers) . "\r\n",
'method' => 'POST',
'content' => json_encode($params)
]
];
$signResponse = file_get_contents($signUrl, false, stream_context_create($options));
$signData = json_decode($signResponse, true);
if (isset($signData["error_code"])) {
echo "签到失败,请检查cookie是否正常或过期,错误代码: {$signData['error_code']}\n";
exit();
}
$mb = ($signData["data"]["sign_daily_reward"] ?? 0) / 2048;
echo json_encode($signData, JSON_PRETTY_PRINT) . "\n";
echo "签到成功,获取到{$mb}MB!\n";
?>
获取cookie
1、登录PC https://pan.quark.cn/list#/list/all
2、F12调出调试键 先点清除网络日记在刷新
3、把这里的cookie值全部复制下来 保存到ck.txt文件中
宝塔定时
每天访问一次sign.php
发表回复