www.gusucode.com > Destoon B2B仿淘宝电子商务网站 UTF8 v6.0源码程序 > destoon/api/weixin/qrcode_bind.php
<?php require '../../common.inc.php'; header("Content-type:image/png"); $_userid or dheader('image/qrcode_error.png'); $auth = isset($auth) ? decrypt($auth) : ''; $auth == $_username.md5(DT_IP.$_SERVER['HTTP_USER_AGENT']) or dheader('image/qrcode_error.png'); $t = $db->get_one("SELECT itemid FROM {$DT_PRE}weixin_user WHERE username='$_username'"); if($t) dheader('image/qrcode_error.png'); $sid = random(9, '123456789'); $db->query("REPLACE INTO {$DT_PRE}weixin_bind (username,sid,addtime) VALUES ('$_username','$sid','$DT_TIME')"); $expire = $DT_TIME - 1800; $db->query("DELETE FROM {$DT_PRE}weixin_bind WHERE addtime<$expire"); require DT_ROOT.'/api/weixin/init.inc.php'; $url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token='.$access_token; $par = '{"expire_seconds": 1800,"action_name": "QR_SCENE","action_info": {"scene": {"scene_id":'.$sid.'}}}'; $arr = $wx->http_post($url, $par); dheader('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.urlencode($arr['ticket'])); ?>