1.远程验证token有效性

This commit is contained in:
2026-04-30 14:39:25 +08:00
parent d9b2ebafa9
commit 487016e037

View File

@@ -466,8 +466,20 @@ class Playx extends Api
$code = $res->getStatusCode();
$data = json_decode(strval($res->getBody()), true);
if ($code !== 200 || empty($data['user_id'])) {
$remoteMsg = $data['message'] ?? '';
$msg = is_string($remoteMsg) && $remoteMsg !== '' ? $remoteMsg : __('Token expiration');
$remoteMsg = '';
if (is_array($data)) {
$candidateMsg = $data['message'] ?? ($data['msg'] ?? ($data['error'] ?? ''));
if (is_string($candidateMsg) && $candidateMsg !== '') {
$remoteMsg = $candidateMsg;
}
}
if ($remoteMsg === '') {
$bodyText = strval($res->getBody());
if ($bodyText !== '') {
$remoteMsg = mb_substr($bodyText, 0, 300);
}
}
$msg = $remoteMsg !== '' ? $remoteMsg : __('Token expiration');
return $this->error($msg, null, 0, ['statusCode' => 401]);
}