From f5ea0add60bcaeaa8ee232a8cbac815a49f657f6 Mon Sep 17 00:00:00 2001 From: wong <106998207@qq.com> Date: Wed, 28 May 2025 15:44:21 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=93=8D=E7=9B=98=E6=89=8B=E3=80=91?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E7=82=B9=E8=B5=9E=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/WebSocketController.php | 26 +++++++++---------- Server/application/command.php | 1 + 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Server/application/api/controller/WebSocketController.php b/Server/application/api/controller/WebSocketController.php index b8a1ea84..37978712 100644 --- a/Server/application/api/controller/WebSocketController.php +++ b/Server/application/api/controller/WebSocketController.php @@ -57,25 +57,25 @@ class WebSocketController extends BaseController $this->authorized = $cachedToken; $this->accountId = $userData['accountId']; } else { - $params = [ - 'grant_type' => 'password', - 'username' => $userData['userName'], - 'password' => $userData['password'] - ]; - - // 调用登录接口获取token + $params = [ + 'grant_type' => 'password', + 'username' => $userData['userName'], + 'password' => $userData['password'] + ]; + + // 调用登录接口获取token $headerData = ['client:kefu-client']; - $header = setHeader($headerData, '', 'plain'); + $header = setHeader($headerData, '', 'plain'); $result = requestCurl('https://kf.quwanzhi.com:9991/token', $params, 'POST', $header); - $result_array = handleApiResponse($result); + $result_array = handleApiResponse($result); - if (isset($result_array['access_token']) && !empty($result_array['access_token'])) { + if (isset($result_array['access_token']) && !empty($result_array['access_token'])) { $this->authorized = $result_array['access_token']; - $this->accountId = $userData['accountId']; - + $this->accountId = $userData['accountId']; + // 将token存入缓存,有效期5分钟 Cache::set($cacheKey, $this->authorized, 300); - } else { + } else { return json_encode(['code'=>400,'msg'=>'获取系统授权信息失败']); } } diff --git a/Server/application/command.php b/Server/application/command.php index cb1a15b8..152597a4 100644 --- a/Server/application/command.php +++ b/Server/application/command.php @@ -30,4 +30,5 @@ return [ 'workbench:autoLike' => 'app\command\WorkbenchAutoLikeCommand', // 工作台自动点赞任务 'workbench:moments' => 'app\command\WorkbenchMomentsCommand', // 工作台朋友圈同步任务 'sync:wechatData' => 'app\command\SyncWechatDataToCkbTask', // 同步微信数据到存客宝 + 'sync:allFriends' => 'app\command\SyncAllFriendsCommand', // 同步所有在线好友 ];