wang hou sheng 10 months ago
parent 7a4bb09b49
commit e148dc082c
  1. 8
      app/api/controller/Wxserver.php
  2. 11
      app/common/library/wxserver/Server.php

@ -10,8 +10,12 @@ class Wxserver extends BaseController
public function index()
{
$obj = new \app\common\library\wxserver\Server();
$data = $obj->getQrcode('wxe3ed157849bd07b5');
return $this->renderSuccess($data);
$img = $obj->getQrcode('wxe3ed157849bd07b5');
$img_url = '';
if ($img) {
$img_url = $this->request->domain(true) . $img;
}
return $this->renderSuccess(compact($img_url));
}
public function verifyTicket()

@ -142,6 +142,9 @@ class Server
$info = $info->toArray();
$access_token = $this->authorizerAccessToken($appid, $info['refresh_token']);
if ($access_token) {
$savePath = root_path() . "public/wxserve/experience";
!is_dir($savePath) && mkdir($savePath, 0755, true);
$savePath .= '/' . $appid . 'jpg';
$url = 'https://api.weixin.qq.com/wxa/get_qrcode?access_token=' . $access_token;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@ -150,12 +153,12 @@ class Server
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 同上
$qrcode_response = curl_exec($ch);
curl_close($ch);
$qrcode_response = json_decode($qrcode_response, true);
var_dump($url);
exit();
if (file_put_contents($savePath, $qrcode_response)) {
return '/wxserve/experience/' . $appid . '.jpg';
}
}
}
return [];
return '';
}
/**

Loading…
Cancel
Save