From fc1b26d8cd2bf5ad5b3286287e2bbe5fb7ddba77 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 11 Apr 2024 11:26:04 +0800 Subject: [PATCH] 1 --- app/common/library/wxserver/Server.php | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index c047bcf8..321b40ce 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -298,7 +298,7 @@ class Server public function authorizerAccessToken($appid) { if (Cache::has($appid . '_authorizer_access_token')) { - //return Cache::get($appid . '_authorizer_access_token'); + return Cache::get($appid . '_authorizer_access_token'); } $refresh_token = $this->getRefreshToken($appid); if ($refresh_token) { @@ -470,21 +470,25 @@ class Server */ public function setDomain($appid, $domain) { - $url = 'https://api.weixin.qq.com/wxa/modify_domain?access_token=' . $this->authorizerAccessToken($appid); - $data['action'] = 'set'; - $data['requestdomain'] = [$domain]; - $data['wsrequestdomain'] = []; - $data['uploaddomain'] = [$domain]; - $data['downloaddomain'] = [$domain]; - $data['udpdomain'] = []; - $data['tcpdomain'] = []; - $result = $this->curlPost($url, json_encode($data)); - $result = json_decode($result, true); - return $result; - if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { - return true; + $token = $this->authorizerAccessToken($appid); + if ($token) { + $url = "https://api.weixin.qq.com/wxa/modify_domain?access_token=$token"; + $data['action'] = 'set'; + $data['requestdomain'] = [$domain]; + $data['wsrequestdomain'] = []; + $data['uploaddomain'] = [$domain]; + $data['downloaddomain'] = [$domain]; + $data['udpdomain'] = []; + $data['tcpdomain'] = []; + $result = $this->curlPost($url, json_encode($data)); + $result = json_decode($result, true); + return $result; + if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { + return true; + } + return false; } - return false; + return []; } public function apiText($authorization_code, $touser)