From 390af05e46dc9e9f3bf59ab691724490771b3060 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:54:58 +0800 Subject: [PATCH] 1 --- app/api/controller/Wxserver.php | 7 +++++++ app/common/library/wxserver/Server.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/app/api/controller/Wxserver.php b/app/api/controller/Wxserver.php index e3634aa5..d2092394 100644 --- a/app/api/controller/Wxserver.php +++ b/app/api/controller/Wxserver.php @@ -13,6 +13,13 @@ use think\facade\Db; class Wxserver extends BaseController { + public function index() + { + $obj = new \app\common\library\wxserver\Server(); + $arr = $obj->setDomainDirectly($this->request->domain(true), 'wxe3ed157849bd07b5'); + return $this->renderSuccess($arr); + + } public function verifyTicket() { diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index ddd6c0ba..9fe3946c 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -462,6 +462,21 @@ class Server return $list; } + public function setDomainDirectly($appid, $domain) + { + $url = 'https://api.weixin.qq.com/wxa/modify_domain_directly?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; + } + public function apiText($authorization_code, $touser) { $url = 'https://api.weixin.qq.com/cgi-bin/component/api_query_auth?component_access_token=' . $this->getComponentAccessToken();