Php development generates two-dimensional codes with parameters in batches, and php batch parameters. Php development generates two-dimensional codes with parameters in batches. The two-dimensional codes with parameters in php batch are very useful for channel marketing and promotion, multiple two-dimensional php development with different scenario values can be obtained to generate two-dimensional codes with parameters in batch, and php batch 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.
Public function createewm () {if (IS_POST) {$ access_token = checkAccessToken ($ this-> token); // get access_token $ json_url =' https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token= '. $ Access_token; $ action_name = $ this-> _ post ('Action _ name'); // generated type (temporary and permanent) $ create_num = $ this-> _ post ('create _ num'); // generated quantity // The Last Generation ID in the database query $ now_secne_id = M ('erweima ') -> where (array ('token' => $ this-> token)-> order ('scene _ id desc ')-> getField ('scene _ id '); // add 1 $ start_secne_id = intval ($ now_secne_id) + 1 to the last edit; $ end_secne_id = intval ($ now_secne_id) + intval ($ create_num ); $ n = 0; for ($ I = $ start_secne_id; $ I <= $ end_s Ecne_id; $ I ++) {$ curl_data = ''; if ($ action_name = 'QR _ SCENE ') {// json data of temporary post $ curl_data = '{"expire_seconds": 1800, "action_name": "QR_SCENE", "action_info": {"scene ": {"scene_id ":'. $ I. '}}}';} if ($ action_name = 'QR _ LIMIT_SCENE') {// permanent post json data $ curl_data = '{"action_name": "QR_LIMIT_SCENE ", "action_info": {"scene": {"scene_id ":'. $ I. '}}}';} $ json_info = json_decode ($ this-> api_notice_increment ($ json _ Url, $ curl_data), true); // This indicates that the data is successfully generated. record the data so that it can be inserted into the database. it is convenient to search for the if ($ json_info ['errcode'] in future statistics! = 40013) {$ data [$ n] ['token'] = $ this-> token; $ data [$ n] ['tid'] = $ json_info ['ticket']; $ data [$ n] ['URL'] = $ json_info ['URL']; $ data [$ n] ['scene _ id'] = $ I; $ data [$ n] ['expire _ seconds '] = $ json_info ['expire _ seconds']; $ data [$ n] ['action _ name'] = $ action_name; $ data [$ n] ['remark'] = ''; $ data [$ n] ['createtime'] = time (); $ n ++;} else {$ this-> error ('Operation failed ');}} if (count ($ data)> 0) {$ res = M ('erweima ')-> addAll ($ data); // Insert data if ($ res) {$ this-> success ('added successfully');} else {$ this-> error ('Operation failed ');}} else {$ this-> error ('Operation failed ');}}}
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 above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.
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...