<?php $user_id = 1; $token = $this->getAccessToken(); $url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" . $token; $ch1 = curl_init(); curl_setopt($ch1, CURLOPT_URL, $url); curl_setopt($ch1, CURLOPT_POST, 1); curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false); //curl_setopt($ch1, CURLOPT_POSTFIELDS, '{"expire_seconds": 604800, "action_name": "QR_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$user_id.'"}}}'); curl_setopt($ch1, CURLOPT_POSTFIELDS, '{"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "'.$user_id.'"}}}'); $c = curl_exec($ch1); $result = @json_decode($c, true); $ticket = $result["ticket"]; $qr_path = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$ticket; $bigImgPath = "xxxxxxxxxxx.png"; $bigImg = imagecreatefromstring(file_get_contents($bigImgPath)); $qCodeImg = imagecreatefromstring(file_get_contents($qr_path)); $save_width = 200; $save_height = 200; list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qr_path); $new_image = imagecreatetruecolor($save_width, $save_height); $s = imagecopyresampled($new_image, $qCodeImg, 0, 0, 0, 0, $save_width, $save_height, $qCodeWidth, $qCodeHight); imagecopymerge($bigImg, $new_image, 265, 370 , 0, 0, $save_width, $save_height, 100); $img_path = time().rand(100000,999999).'.jpg'; imagejpeg($bigImg,'xxxxxxx/images/'.$img_path); include $this->template('code');