Development-Php generates two-dimensional codes with parameters in batches, and php parameters. Development-Php generates two-dimensional codes with parameters in batches. The two-dimensional codes with parameters in php parameters are very useful for channel marketing and promotion, you can obtain multiple two-dimensional development projects with different scenario values -- generate two-dimensional codes with parameters in Php in batches, and generate php parameters.
The two-dimensional code with parameters is very useful for channel marketing and promotion. multiple two-dimensional codes with different scenario values can be obtained. after a user scans the QR code, the public number can receive event push, the good news is that we have activated this interface. let's take a look at it.
For details about the interface, see the public platform developer documentation (http://mp.weixin.qq.com/wiki/18/28fc21e7ed87bec960651f0ce873ef8a.html), I am here on the code directly.
Demo diagram:
Due to the limited generation of QR codes with parameters, all codes are generated by serial numbers and will be accumulated at the next generation.
In addition, remarks are provided to facilitate future statistics.
1 public function createewm () {2 if (IS_POST) {3 $ access_token = checkAccessToken ($ this-> token); // get access_token 4 $ json_url =' https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token= '. $ Access_token; 5 6 $ action_name = $ this-> _ post ('Action _ name'); // generated type (temporary and permanent) 7 $ create_num = $ this-> _ post ('create _ num '); // generated quantity 8 9 // the last 10 $ now_secne_id = M ('erweima ') generated in the database query ') -> where (array ('token' => $ this-> token)-> order ('scene _ id desc ')-> getField ('scene _ id '); 11 12 // add 113 $ start_secne_id = intval ($ now_secne_id) + 1 to the last edit; 14 $ end_secne_id = intval ($ now_secne_id) + intval ($ create_num ); 15 $ n = 0; 16 for ($ I = $ Start_secne_id; $ I <= $ end_secne_id; $ I ++) {17 $ curl_data = ''; 18 if ($ action_name = 'QR _ SCENE ') {19 // json data of temporary post 20 $ curl_data = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene ": {"scene_id ":'. $ I. '}}}'; 21} 22 23 if ($ action_name = 'QR _ LIMIT_SCENE ') {24 // json data of permanent post 25 $ curl_data = '{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id ":'. $ I. '}}}'; 26} 27 $ json_ I Nfo = json_decode ($ this-> api_notice_increment ($ json_url, $ curl_data), true); 28 29 // this indicates that the data is generated successfully, and the data is recorded for insertion into the database, for future statistics, search for 30 if ($ json_info ['errcode']! = 40013) {31 $ data [$ n] ['token'] = $ this-> token; 32 $ data [$ n] ['tid'] = $ json_info ['ticket']; 33 $ data [$ n] ['URL'] = $ json_info ['URL']; 34 $ data [$ n] ['scene _ id'] = $ I; 35 $ data [$ n] ['expire _ seconds '] = $ json_info ['expire _ seconds']; 36 $ data [$ n] ['action _ name'] = $ action_name; 37 $ data [$ n] ['remark'] = ''; 38 $ data [$ n] ['createtime'] = time (); 39 $ n ++; 40} else {41 $ this-> error ('Operation failed '); 42} 43} 44 45 if (count ($ data)> 0) {46 $ res = M ('erweima ')-> addAll ($ data ); // Insert data 47 if ($ res) {48 $ this-> success ('added successfully '); 49} else {50 $ this-> error ('Operation failed'); 51} 52} else {53 $ this-> error ('Operation failed '); 54} 55} 56}
function api_notice_increment($url, $data){ $ch = curl_init(); $header = "Accept-Charset: utf-8"; 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($curl, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_AUTOREFERER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $tmpInfo = curl_exec($ch); if (curl_errno($ch)) { //curl_close( $ch ) return $ch; }else{ //curl_close( $ch ) return $tmpInfo; } curl_close( $ch ) ; }
It's easy. it's basically enough. just take it if you like it.
The QR code with parameters in timeline is very useful for channel marketing and promotion, and multiple two-dimensional codes with different scenario values can be obtained...