From 077d6c60d90d5f083c9d34ea3c42808d70ebdc45 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Tue, 9 Apr 2024 23:58:10 +0800 Subject: [PATCH] 1 --- app/common/library/wxserver/Server.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 19f5f0c2..2819be01 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -144,21 +144,17 @@ class Server if ($access_token) { $savePath = root_path() . "public/wxserve/experience"; !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; - $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); - dump($qrcode_response); - exit(); -// $newFile = fopen($savePath, "a"); -// fwrite($newFile, $qrcode_response); -// fclose($newFile); - return '/wxserve/experience/' . $appid . '.jpg'; + $client = new \Qiniu\Http\Client(); + $response = $client->get($url); + $res = $response->body(); + if ($res) { + $newFile = fopen($savePath, "a"); + fwrite($newFile, $res); + fclose($newFile); + return '/wxserve/experience/' . $appid . '.jpg'; + } } } return '';