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 '';