wang hou sheng 8 months ago
parent b55cb5bfc3
commit 077d6c60d9
  1. 24
      app/common/library/wxserver/Server.php

@ -144,21 +144,17 @@ class Server
if ($access_token) { if ($access_token) {
$savePath = root_path() . "public/wxserve/experience"; $savePath = root_path() . "public/wxserve/experience";
!is_dir($savePath) && mkdir($savePath, 0755, true); !is_dir($savePath) && mkdir($savePath, 0755, true);
$savePath .= '/' . $appid . 'jpg'; $savePath .= '/' . $appid . 'jpg'; //Client
$url = 'https://api.weixin.qq.com/wxa/get_qrcode?access_token=' . $access_token; $url = 'https://api.weixin.qq.com/wxa/get_qrcode?access_token=' . $access_token;
$ch = curl_init(); $client = new \Qiniu\Http\Client();
curl_setopt($ch, CURLOPT_URL, $url); $response = $client->get($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = $response->body();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 如果你的环境没有安装证书,可以设置为 false,但生产环境不建议这样做 if ($res) {
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // 同上 $newFile = fopen($savePath, "a");
$qrcode_response = curl_exec($ch); fwrite($newFile, $res);
curl_close($ch); fclose($newFile);
dump($qrcode_response); return '/wxserve/experience/' . $appid . '.jpg';
exit(); }
// $newFile = fopen($savePath, "a");
// fwrite($newFile, $qrcode_response);
// fclose($newFile);
return '/wxserve/experience/' . $appid . '.jpg';
} }
} }
return ''; return '';

Loading…
Cancel
Save