生成带参数的临时二维码和永久二维码
生成临时二维码
public function getTimeQrcode(){
//1、获取ticket票据
$access_token = $this->get_access_token();
$url="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token";
$array = array(
"expire_seconds" => 604800,//24*60*60*7 七天有效期
"action_name"=>"QR_SCENE",
"action_info"=>array(
"scene"=>array(
"scene_id"=>2000//二维码附带的参数
)
)
);
$postJson = json_encode($array);
$res = $this->http_curl($url,"post","json",$postJson);
$ticket = $res['ticket'];
$url="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket);
echo "
";
} 生成永久二维码
public function getForeverQrcode(){
//1、获取ticket票据
$access_token = $this->get_access_token();
$url="https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=$access_token";
$array = array(
"action_name"=>"QR_SCENE",
"action_info"=>array(
"scene"=>array(
"scene_id"=>3000//二维码附带的参数
)
)
);
$postJson = json_encode($array);
$res = $this->http_curl($url,"post","json",$postJson);
$ticket = $res['ticket'];
$url="https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=".urlencode($ticket);
echo "
";
}