From 7ee46d8019c617fad5c8a26146aa63426d4f678a Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 11 Apr 2024 10:35:07 +0800 Subject: [PATCH] 1 --- app/api/controller/Wxserver.php | 1 - app/common/library/wxserver/Server.php | 13 +++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/api/controller/Wxserver.php b/app/api/controller/Wxserver.php index f099d61a..e3634aa5 100644 --- a/app/api/controller/Wxserver.php +++ b/app/api/controller/Wxserver.php @@ -77,7 +77,6 @@ class Wxserver extends BaseController $data['Content'] = 'TESTCOMPONENT_MSG_TYPE_TEXT_callback'; echo $this->responseText($data); } elseif (strpos($data['Content'], 'QUERY_AUTH_CODE:') !== false) { - Db::table('yoshop_wx_server')->insertGetId(['content' => '给客服发送消息', 'created_at' => $time]); $query_auth_code = trim(str_replace("QUERY_AUTH_CODE:", "", $data['Content'])); $obj->apiText($query_auth_code, $data['FromUserName']); } diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 94ea187c..ddd6c0ba 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -470,17 +470,14 @@ class Server $result = $this->curlPost($url, json_encode($data)); $result = json_decode($result, true); if (!empty($result['authorization_info']['authorizer_access_token'])) { - Db::table('yoshop_wx_server')->insertGetId(['content' => '获取到给客户发送信息token', 'created_at' => date('Y-m-d H:i:s')]); $token = $result['authorization_info']['authorizer_access_token']; $url = 'https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=' . $token; - $data = []; - $data['touser'] = $touser; - $data['msgtype'] = 'text'; - $data['text'] = [ - 'content' => $authorization_code . '$_from_api', + $data = [ + 'touser' => $touser, + 'msgtype' => 'text', + 'text' => ['content' => $authorization_code . '_from_api'], ]; - $arr = $this->curlPost($url, json_encode($data)); - Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($arr), 'created_at' => date('Y-m-d H:i:s')]); + $this->curlPost($url, json_encode($data)); } }