小程序的二维码在哪找-获取带参数的小程序二维码-小程序二维码
1.微信小程序二维码官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/api/qrcode.html
2.php具体实现代码:
/**生成带参数的小程序二维码**/publicfunctiongetQRCode($auth){//获取access_token$access_token=json_decode(file_get_contents('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$applet['appid'].'&secret='.$applet['appsecret']));if(!isset($access_token)){returnfalse;}//拼接微信服务端获取二维码需要的url$url='https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token='.$access_token;$data['auth']=$auth;$data['path']="pages/index/index";$json=json_encode($data);$result=$this-api_notice_increment($url,$json);header('Content-Type:image/jpeg');echo$result;die;}publicfunctionapi_notice_increment($url,$data){$ch=curl_init();curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch,CURLOPT_CUSTOMREQUEST,"POST");curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0(compatible;MSIE5.01;WindowsNT5.0)');curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);curl_setopt($ch,CURLOPT_AUTOREFERER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$data);curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);$tmpInfo=curl_exec($ch);if(curl_errno($ch)){curl_close($ch);return$ch;}else{curl_close($ch);return$tmpInfo;}}3.tip:1:此种方式采用的微信生成二维码的方法一,数量有限,好处path长度够长128,能传递绝大部分加密后的信息2:如果不需要加密,或者加密后字符串长度在32位以内,方法二是最好选择,生成数量没有限制。
4.最后附上进入小程序页面后参数接收方法:
onLoad:function(options){this.getParamsCode(options);},//获取二维码参数getParamsCode:function(options){if(options.auth!=undefined){app.globalData.pcUserInfo={auth:options.auth}}}TAG标签: 微信小程序小程序的二维码在哪找小程序二维码
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

