getQrcode($scene, $page); // 保存到文件 file_put_contents($savePath, $content); return $savePath; } /** * 获取网络图片到临时目录 * @param $wxappId * @param $url * @param string $mark * @return string */ protected function saveTempImage($wxappId, $url, $mark = 'temp') { $dirPath = RUNTIME_PATH . 'image' . '/' . $wxappId; !is_dir($dirPath) && mkdir($dirPath, 0755, true); $savePath = $dirPath . '/' . $mark . '_' . md5($url) . '.png'; if (file_exists($savePath)) return $savePath; $ch = curl_init($url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); $img = curl_exec($ch); curl_close($ch); $fp = fopen($savePath, 'w'); fwrite($fp, $img); fclose($fp); return $savePath; } }