微信公众号生成永久二位码

只 需要微信公众号的appid和appsecret,下面方法是生成带场景值的永久二维码        

            $appid = $Wechat['app_id'];
            $apret = $Wechat['app_secret'];
            // 获取token
            $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$apret";
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //不输出内容
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            $json = curl_exec($ch);
            curl_close($ch);
            $arr = json_decode($json, true);
            $token = $arr['access_token'];
            $json_url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $token;
            $curl_data = '{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str":"' . $userId . '"}}}';
            $json_info = json_decode(api_notice_increment($json_url, $curl_data), true);
            $imgpath = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" . urlencode($json_info['ticket']);
            $data['code_address'] = $json_info['ticket'];
阅读更多
换一批

没有更多推荐了,返回首页