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("号商api token无效"); return 2; } if($responseData['code'] == 2){ Log::warning("ws 在第三方api不存在 ws号".$phone); return 3; } return -1; } }