function get_qr($card,$APPID,$SECRET){
$accessTokenUrl = ' https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$APPID.'&secret='.$SECRET
;
$ch = curl_init($accessTokenUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$info = curl_exec($ch);
$dataJson = json_decode($info, true);
$access_token=$dataJson['access_token'];
// echo $access_token;
if( !isset($access_token) ){exit( '获取access_token失败!' );}
$url = " https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$access_token
;
if($_POST['type']==1){
$data='{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$card.'"}}}';}
else
{
echo "此二维码为临时二维码,有效期只有".$_POST['expire'].'秒<br/>';
$data='{ "expire_seconds": '.$_POST['expire'].', "action_name": "QR_SCENE", "action_info": { "scene": { "scene_id": '.$card.' } }}';}
$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; MSIE 5.01; Windows NT 5.0)');
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
curl_close($ch);
$tmpInfo1 = (array)json_decode($tmpInfo);
return $tmpInfo1;
}
$accessTokenUrl = ' https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$APPID.'&secret='.$SECRET
;
$ch = curl_init($accessTokenUrl);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20100101 Firefox/21.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$info = curl_exec($ch);
$dataJson = json_decode($info, true);
$access_token=$dataJson['access_token'];
// echo $access_token;
if( !isset($access_token) ){exit( '获取access_token失败!' );}
$url = " https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$access_token
;
if($_POST['type']==1){
$data='{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$card.'"}}}';}
else
{
echo "此二维码为临时二维码,有效期只有".$_POST['expire'].'秒<br/>';
$data='{ "expire_seconds": '.$_POST['expire'].', "action_name": "QR_SCENE", "action_info": { "scene": { "scene_id": '.$card.' } }}';}
$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; MSIE 5.01; Windows NT 5.0)');
@curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$tmpInfo = curl_exec($ch);
curl_close($ch);
$tmpInfo1 = (array)json_decode($tmpInfo);
return $tmpInfo1;
}