wanghousheng 5 months ago
parent 56490d1e5c
commit c5fa0b90a7
  1. 10
      app/admin/controller/Wxserve.php
  2. 13
      app/common/library/wxserver/Server.php

@ -196,13 +196,15 @@ class Wxserve extends Controller
public function getVersion(): Json public function getVersion(): Json
{ {
$appid = $this->request->get('appid'); $appid = $this->request->get('appid');
if ($appid) { if (!$appid) {
return $this->renderError('缺少参数appid');
}
$obj = new Server(); $obj = new Server();
if ($obj->getVersioninfo($appid)) { $msg = $obj->getVersioninfo($appid);
if ($msg == 'ok') {
return $this->renderSuccess('success'); return $this->renderSuccess('success');
} }
} return $this->renderError($msg);
return $this->renderError('操作失败');
} }
/** /**

@ -283,16 +283,19 @@ class Server
/** /**
* @notes:获取版本信息 * @notes:获取版本信息
* @param $appid * @param $appid
* @return bool * @return mixed|string
* @author: wanghousheng * @author: wanghousheng
*/ */
public function getVersioninfo($appid): bool public function getVersioninfo($appid)
{ {
$msg = '未知错误';
$access_token = $this->authorizerAccessToken($appid); $access_token = $this->authorizerAccessToken($appid);
$url = 'https://api.weixin.qq.com/wxa/getversioninfo?access_token=' . $access_token; $url = 'https://api.weixin.qq.com/wxa/getversioninfo?access_token=' . $access_token;
$result = $this->curlPost($url, '{}'); $result = $this->curlPost($url, '{}');
$result = json_decode($result, true); $result = json_decode($result, true);
if ($result && !empty($result['errmsg']) && $result['errmsg'] == 'ok') { if ($result && !empty($result['errmsg'])) {
$msg = $result['errmsg'];
if ($msg == 'ok') {
$up = []; $up = [];
if (!empty($result['exp_info'])) { if (!empty($result['exp_info'])) {
$up['exp_info'] = json_encode($result['exp_info']); $up['exp_info'] = json_encode($result['exp_info']);
@ -304,9 +307,9 @@ class Server
$model = new WxserverAccount(); $model = new WxserverAccount();
$model->update($up, ['appid' => $appid]); $model->update($up, ['appid' => $appid]);
} }
return true;
} }
return false; }
return $msg;
} }
/** /**

Loading…
Cancel
Save