From 45ff01a8b5f6610be725b1adc67740f02e1e1b4d Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:30:54 +0800 Subject: [PATCH] 1 --- app/api/controller/Wxserver.php | 9 ++++----- app/common/library/wxserver/Server.php | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/api/controller/Wxserver.php b/app/api/controller/Wxserver.php index 735c1a39..e0aeedfe 100644 --- a/app/api/controller/Wxserver.php +++ b/app/api/controller/Wxserver.php @@ -16,10 +16,10 @@ class Wxserver extends BaseController public function index() { $appid = 'wx74c7a92ae5ffbcb6'; - $template_id = 6; $obj = new \app\common\library\wxserver\Server(); - $arr = $obj->getQrcode($appid); - return $this->renderSuccess(['arr' => $arr]); + $arr = $obj->release('wxe3ed157849bd07b5'); + $arr2 = $obj->release('wx896520d9d03f108f'); + return $this->renderSuccess(['arr' => $arr, 'arr2' => $arr2]); } @@ -51,7 +51,6 @@ class Wxserver extends BaseController public function callback($appid) { $time = date('Y-m-d H:i:s'); - Db::table('yoshop_wx_server')->insertGetId(['content' => '推送开始', 'created_at' => $time]); $obj = new \app\common\library\wxserver\Server(); $signature = $this->request->get('signature'); $timestamp = $this->request->get('timestamp'); @@ -60,7 +59,6 @@ class Wxserver extends BaseController if ($obj->checkSignature($signature, $timestamp, $nonce)) { $xmlData = file_get_contents("php://input"); if ($xmlData) { - Db::table('yoshop_wx_server')->insertGetId(['content' => $xmlData, 'created_at' => $time]); $data = $obj->decryptXml($xmlData); Db::table('yoshop_wx_server')->insertGetId(['content' => json_encode($data), 'created_at' => $time]); if (!empty($data['MsgType'])) { @@ -68,6 +66,7 @@ class Wxserver extends BaseController $up = []; if ($data['Event'] == 'weapp_audit_success') { $up['audit_status'] = 2; + $obj->release($appid);//审核通过发布版本 } elseif ($data['Event'] == 'weapp_audit_fail') { $up['audit_status'] = 3; } elseif ($data['Event'] == 'weapp_audit_delay') { diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 80c288c0..f0d6b8b0 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -241,6 +241,26 @@ class Server return false; } + /** + * @notes:发布已经审核通过的小程序 + * @param $appid + * @return bool + * @author: wanghousheng + */ + public function release($appid): bool + { + $access_token = $this->authorizerAccessToken($appid); + if ($access_token) { + $url = 'https://api.weixin.qq.com/wxa/release?access_token=' . $access_token; + $result = $this->curlPost($url, '{}'); + $result = json_decode($result, true); + if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { + return true; + } + } + return false; + } + /** * @notes:获取版本信息 * @param $appid