标签:
本人小菜鸟一只,为了自我学习和交流PHP(jquery,linux,lamp,shell,javascript,服务器)等一系列的知识,小菜鸟创建了一个群。希望光临本博客的人可以进来交流。寻求共同发展。搭建平台。本人博客也有许多的技术文档,希望可以为你提供一些帮助。QQ群: 191848169 QQ:450225664
//生成带参数的临时二维码 用于绑定微信号 $memcache = new Memcache; $memcache->addServer(‘127.0.0.1‘,11211); //检测是否有重复 do{ $rand_code = rand(20000,30000); }while($memcache->get($rand_code)); //将user_id 存入memcache 缓存 $memcache->set($rand_code,$_SESSION[‘user_id‘],3600); //获得access_token; // $resultd =file_get_contents(‘https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxdafc634908061c97&secret=584d57925a832e76676adeabb785dce8‘); // $resultd = json_decode($resultd); // $access_token = $resultd->access_token; $access_token = WXBaseFun::getAccessToken(); //获得ticket $qrcode = ‘{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": ‘.$rand_code.‘}}}‘; $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token"; $resulstd = https_post($url,$qrcode); $jsoninfo = json_decode($resulstd,true); $ticket = $jsoninfo[‘ticket‘]; //下载二维码图片 $urls = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket); $imageinfo = downloadimagefromweixin($urls); $filename = time().‘_qrcode.jpg‘; $local_file = fopen(‘qrcode/‘.$filename, ‘w‘); if(false !==$local_file){ if(false !==fwrite($local_file, $imageinfo[‘body‘])){ fclose($local_file); } } //分配生成的图片 $smarty->assign(‘code_img‘,$filename); //生成带参数的二维码结束
标签:
原文地址:http://blog.csdn.net/yafei450225664/article/details/46439341