所属分类:PHP实例-常用实例教程
有项目刚用到,现在分享出来,也是从别的地方找到的
public function getwxaqrcode() { $access_token = $this->AccessToken(); //接口A: //$url = 'https://api.weixin.qq.com/wxa/getwxacode?access_token='.$access_token; //$path="pages/mine/mine/mine?query=1"; //$width=430; //$data='{"path":"'.$path.'","width":'.$width.'}'; //接口B: $url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $access_token; $scene = 'shopid=gd123&cm=comma&hi=abc'; $width = 100; $auto_color = 'false'; //默认值是false,自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调; $line_color = '{"r":"0","g":"0","b":"0"}'; //auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"} $data = '{"scene":"' . $scene . '","width":' . $width . ',"auto_color":' . $auto_color . ',"line_color":' . $line_color . '}'; //接口C: //$url = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token='.$access_token; //$path="pages/mine/mine/mine?query=1"; //$width=430; //$data='{"path":"'.$path.'","width":'.$width.'}'; $return = $this->request_post($url, $data); // return var_dump($return); //将生成的小程序码存入相应文件夹下 $erweima = 'erweima.jpg'; file_put_contents($erweima, $return); return '<img src="' . $erweima . '">'; }