feat: 添加删除 WS 号功能并优化发送代码逻辑
This commit is contained in:
parent
a32b395db0
commit
0d758464e3
|
@ -81,13 +81,40 @@ class SendCode
|
|||
return $responseData['status'];
|
||||
}
|
||||
if($responseData['code'] == 1){
|
||||
Log::warning("号商api token无效");
|
||||
// Log::warning("号商api token无效");
|
||||
return 2;
|
||||
}
|
||||
if($responseData['code'] == 2){
|
||||
Log::warning("ws 在第三方api不存在 ws号".$phone);
|
||||
// Log::warning("ws 在第三方api不存在 ws号".$phone);
|
||||
return 3;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
/**
|
||||
* 删除ws号
|
||||
* https://apifox.com/apidoc/shared-fc04a238-fa44-4e60-b9eb-ef2fe95a52e1
|
||||
* code 0成功1 token无效 2 WS号不存在 3 不能删除在线的WS号
|
||||
*/
|
||||
public static function delWS($phone)
|
||||
{
|
||||
|
||||
$client = new Client(); // 创建 Guzzle 客户端
|
||||
|
||||
// 请求数据
|
||||
$data = [
|
||||
"token" => self::$token,
|
||||
"wsNumber" => $phone,
|
||||
];
|
||||
|
||||
// 发送 POST 请求
|
||||
$response = $client->post('https://dx1.rocketgo.vip/ex-api/biz/api/delWS', [
|
||||
'json' => $data, // 以 JSON 格式发送数据
|
||||
]);
|
||||
// 获取响应体内容
|
||||
$body = $response->getBody();
|
||||
$responseData = json_decode($body, true); // 如果返回的是 JSON 格式,解析它
|
||||
if ($responseData['code'] != 0) {
|
||||
Log::warning("ws:".$phone."删除失败 Code:".$responseData['code']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ class Task2
|
|||
}
|
||||
if ($status == 3) {
|
||||
// 如果账户不存在直接删除
|
||||
SendCode::send_code($value->phone);
|
||||
// $value->delete();
|
||||
$value->status = 0;
|
||||
$value->last_time = $currentTimestamp;
|
||||
|
|
Loading…
Reference in New Issue