wang hou sheng 8 months ago
parent 6e295949a5
commit 45ff01a8b5
  1. 9
      app/api/controller/Wxserver.php
  2. 20
      app/common/library/wxserver/Server.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') {

@ -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

Loading…
Cancel
Save