我给你贴下我写的
/**
* 获取小程序二维码
* @param $scene 访问参数
* @param string $page 二维码页面
* @param bool $oss 是否开启 oss
* @return bool
*/
public function getWXACodeUnlimit($scene,$page = ‘’,$oss = true)
{
$token = $this->token();
if (empty($page)) return false;
$data = [
‘scene’ => $scene,
‘page’ => $page,
];
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=’.$token;
$result = $this->request_post($url,$data);
$msg = json_decode($result,true);
if ($msg) return false;
$path = ‘./download/qrcode/’.date(‘Y/m/d’);
if (!file_exists($path)){
mkdir($path,0777,true);
}
$img = $path.’/’.md5($scene).’.png’;
file_put_contents($img,$result);
if ($oss){
return AliOssUploads::aliyunOssUploadImages($img,true);
}else{
return $img;
}
}