94 lines
2.6 KiB
PHP
94 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Utils\API;
|
|
|
|
use GuzzleHttp\Client;
|
|
use support\Log;
|
|
|
|
/**
|
|
* 第三方api发送上号请求
|
|
*/
|
|
class SendCode
|
|
{
|
|
|
|
protected static $token = 'druid_ccefa62b-243a-4bdb-8460-89f3b36e79f8';
|
|
/**
|
|
* 发送验证码
|
|
* code 状态码 0 成功 1 token无效或已过期 2 端口不足 3 账号已存在 int
|
|
* msg 结果描述 string
|
|
*/
|
|
public static function send_code($phone)
|
|
{
|
|
$client = new Client(); // 创建 Guzzle 客户端
|
|
// 请求数据
|
|
$data = [
|
|
"token" => self::$token,
|
|
"phoneNumber" => $phone,
|
|
"business" => 0,
|
|
];
|
|
|
|
// 发送 POST 请求
|
|
$response = $client->post('https://dx1.rocketgo.vip/ex-api/biz/api/merchant/scanCode', [
|
|
'json' => $data, // 以 JSON 格式发送数据
|
|
]);
|
|
|
|
// 获取响应体内容
|
|
$body = $response->getBody();
|
|
$responseData = json_decode($body, true); // 如果返回的是 JSON 格式,解析它
|
|
return $responseData;
|
|
}
|
|
/**
|
|
* 获取验证码
|
|
*/
|
|
public static function get_code($phone)
|
|
{
|
|
$client = new Client(); // 创建 Guzzle 客户端
|
|
|
|
// 请求数据
|
|
$data = [
|
|
"token" => self::$token,
|
|
"phoneNumber" => $phone,
|
|
];
|
|
|
|
// 发送 POST 请求
|
|
$response = $client->post('https://dx1.rocketgo.vip/ex-api/biz/api/merchant/getScanCode', [
|
|
'json' => $data, // 以 JSON 格式发送数据
|
|
]);
|
|
|
|
// 获取响应体内容
|
|
$body = $response->getBody();
|
|
$responseData = json_decode($body, true); // 如果返回的是 JSON 格式,解析它
|
|
return $responseData;
|
|
}
|
|
/**
|
|
* 检测是否在线
|
|
* https://apifox.com/apidoc/shared-c08671dd-4e9d-44dd-a2a1-ec4b8316a81f
|
|
* 0 在线 1不在线 2token无效 3WS号不存在
|
|
* code
|
|
*/
|
|
public static function get_ws_status($phone)
|
|
{
|
|
|
|
$client = new Client(); // 创建 Guzzle 客户端
|
|
|
|
|
|
$url = "https://dx1.rocketgo.vip/ex-api/biz/api/wsStatus?wsNumber=" . $phone . "&token=".self::$token;
|
|
// 发送 POST 请求
|
|
$response = $client->get("$url");
|
|
$body = $response->getBody();
|
|
$responseData = json_decode($body, true); // 如果返回的是 JSON 格式,解析它
|
|
if ($responseData['code'] == 0) {
|
|
return $responseData['status'];
|
|
}
|
|
if($responseData['code'] == 1){
|
|
Log::warning("token无效");
|
|
return 2;
|
|
}
|
|
if($responseData['code'] == 2){
|
|
echo('2WS号不存在');
|
|
return 3;
|
|
}
|
|
return -1;
|
|
}
|
|
}
|