wang hou sheng 8 months ago
parent 29b20c0223
commit 9edc569277
  1. 7
      app/api/controller/Wxserver.php
  2. 33
      app/common/library/wxserver/Server.php

@ -7,6 +7,13 @@ use cores\BaseController;
class Wxserver extends BaseController
{
public function index()
{
$obj = new \app\common\library\wxserver\Server();
$data = $obj->getQrcode('wxe3ed157849bd07b5');
return $this->renderSuccess($data);
}
public function verifyTicket()
{
$xmlData = file_get_contents("php://input");

@ -126,7 +126,38 @@ class Server
}
/**
* @notes:发布版本
* @notes:获取体验码
* @param $appid
* @return array|mixed
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
* @author: wanghousheng
*/
public function getQrcode($appid)
{
$model = new WxserverAccount();
$info = $model->where(['appid' => $appid])->find();
if (!empty($info)) {
$info = $info->toArray();
$access_token = $this->authorizerAccessToken($appid, $info['refresh_token']);
if ($access_token) {
$url = 'https://api.weixin.qq.com/wxa/get_qrcode?access_token=' . $access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 如果你的环境没有安装证书,可以设置为 false,但生产环境不建议这样做
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 同上
$qrcode_response = curl_exec($ch);
curl_close($ch);
return json_decode($qrcode_response, true);
}
}
return [];
}
/**
* @notes:发布体验版
* @param $appid
* @param $template_id
* @return bool

Loading…
Cancel
Save