From 5ca653d9ca71c65523922e3c9dcf37bacc7f979d Mon Sep 17 00:00:00 2001 From: "zhangf@suq.cn" Date: Wed, 17 Dec 2025 15:06:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(user):=20=E5=A4=84=E7=90=86API=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=93=8D=E5=BA=94=E5=B9=B6=E6=8A=9B=E5=87=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 解析API返回的JSON数据 - 检查errorCode字段是否为空 - 如果存在错误则抛出ApiException异常 - 成功时返回固定的成功消息结构体 - 优化了cURL请求后的数据处理逻辑 --- app/service/user/ApiService.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/service/user/ApiService.php b/app/service/user/ApiService.php index 329be13..ee2fd70 100644 --- a/app/service/user/ApiService.php +++ b/app/service/user/ApiService.php @@ -84,7 +84,13 @@ class ApiService extends BaseService curl_setopt($ch, CURLOPT_POSTFIELDS, $result); $output = curl_exec($ch); curl_close($ch); - return json_decode($output, true); + $result = json_decode($output, true); + if ($result['errorCode'] != '') { + throw new ApiException($result['message']); + } + return [ + 'msg' => 'success' + ]; } } \ No newline at end of file