Explanation of generating two-dimensional code with parameters in micro-credit development
In the micro-trust platform developers, in the "account Management" where there is a function is "to generate a two-dimensional code with parameters," through the generated two-dimensional code, as long as the micro-letter sweep, will automatically push the incident to the micro-public number
The data that is pushed to the developer's Web site with a micro-letter sweep is as follows:
<xml><tousername><! [cdata[gh_452****b0f2]]></tousername>
<fromusername><![ Cdata[oz1fvs4d****7fmfrcbc57o]]></fromusername>
<CreateTime>1429416610</CreateTime>
<msgtype><! [cdata[event]]></msgtype>
<event><![ Cdata[scan]]></event>
<eventkey><![ Cdata[155120hzw]]></eventkey>
<ticket><![ Cdata[gqh17zoaaaaaaaaaasxodhr****s9xl28waunrm1bsv1zjz0vjce8tbufmaaieccozvqmeaaaaaa==]]></ticket>
</xml>
Can be seen is a XMLSTK format of data, the event scan in the scan, Eventkey is the generation of two-dimensional code in the JSON set the value, Eventkey can be designated by themselves, the other are micro-letter platform Default ... By customizing the Eventkey data, you can automatically reply to the specified data
For example: I want to do a guessing game, each riddle has a unique number, this number can be set to Eventkey value, and then others scan with the parameters of two-dimensional code, will be the number of riddles (Eventkey) passed over, and then automatically reply to the answer to the user by number .... That is, to take out a micro-letter sweep to know the answer.
More application of the scene please free play, such as: Sweep, collect red envelopes and other functions can also be achieved.
Micro-credit Official development document:
In order to meet the needs of User channel extension analysis, the public platform provides an interface to generate two dimensional code with parameters. Using this interface, you can get a number of two-dimensional codes with different scene values, and the public number can receive the event push after the user scans.
There are currently 2 types of two-dimensional code, which is a temporary two-dimensional code and a permanent two-dimensional code, the former has an expiration time, the maximum is 1800 seconds, but can generate a large number, the latter has no expiration time, a small number (current parameters only support 1--100000). Two two-dimensional codes are suitable for account binding, user source statistics and other scenarios.
When a user scans a two-D code with scene value, the following two events may be pushed:
If the user has not yet paid attention to the public number, then the user can focus on the public number, after the micro-letter will be concerned with the scene value of the event to push the developer.
If the user has paid attention to the public number, the user will automatically enter the session after the scan, and the micro-letter will also be sent to the developer with the scene value scan event.
The process of getting a two-dimensional code with parameters involves two steps, first creating a two-dimensional code ticket, and then swapping the ticket to the specified URL for a two-dimensional code.
Ticket the meaning of the word I checked the Baidu dictionary, said "tickets, tickets," meaning, that is, through tickets to exchange for two-dimensional code.
In exchange for, in fact, is to add ticket to the last side of the URL, that is, the form of xxxx.com/xxx.php?ticket=xxxx
The real effect is as follows:
One of the ticket=xxx is the ticket value that is obtained.
Micro-credit official documents are as follows:
Each time you create a two-dimensional code ticket need to provide a developer's own set of parameters (SCENE_ID), respectively, to introduce the temporary two-dimensional code and the permanent two-dimensional code to create two-dimensional code ticket process.
The maximum value of the scene_id is 100,000, the requested method is post, and the requested URL is the same.
Post data format: JSON
Post Data example: {"Expire_seconds": 1800, "Action_name": "Qr_scene", "Action_info": {"SCENE": {"scene_id": 123}}}
Expire_seconds indicates the number of seconds expired, and if this parameter is included, it represents a temporary two-dimensional code that is 3 minutes long and expires.
Examples of requests for permanent two-dimensional code:
Post data format: JSON
Post Data example: {"Action_name": "Qr_limit_scene", "Action_info": {"SCENE": {"scene_id": 123}}}
Alternatively, you can use the following post data to create a two-dimensional code parameter in the form of a string:
{"Action_name": "Qr_limit_str_scene", "Action_info": {"SCENE": {"scene_str": "123"}}}
Notice here that the Scene_str table asks for a string, that is, the Eventkey value in the pushed data is a string, the string is double quotes, and you can send English characters.
If the maximum value of the SCENE_ID permanent two-dimensional code is 100,000, it can only be a number without double quotes.
And the request is post, the data format is JSON
Parameter description
| Parameters |
Description |
| Expire_seconds |
The two-dimensional code valid time, in seconds. Max no more than 1800. |
| Action_name |
Two-dimensional code type, Qr_scene is temporary, Qr_limit_scene is permanent, Qr_limit_str_scene is a permanent string parameter value |
| Action_info |
Two-dimensional code details |
| scene_id |
Scene value ID, temporary two-dimensional code is 32-bit non-0 integral type, permanent two-dimensional code maximum value is 100000 (currently parameter only supports 1--100000) |
| Scene_str |
Scene value ID (id as String), string type, length limit 1 to 64, only permanent two-dimensional code supports this field |
Return description
Correct JSON returns the result:
{"Ticket": "gqh47joaaaaaaaaaasxodhrwoi8vd2vpeglulnfxlmnvbs9xl2taz2z3tvrtnzjxv1brb3zhymjjaaiez23suwmemm3suw==", " Expire_seconds ":", "url": "Http:\/\/weixin.qq.com\/q\/kzgfwmtm72wwpkovabbi"}
| Parameters |
Description |
| Ticket |
Obtains the two-dimensional code ticket, by virtue of this ticket can in the valid time exchange for the two-dimensional code. |
| Expire_seconds |
The valid time of the two-dimensional code, in seconds. Max no more than 1800. |
| Url |
Two-dimensional code image after the resolution of the address, the developer can generate the required two-dimensional code image based on the address |
Bad JSON return Example:
{"Errcode": 40013, "errmsg": "Invalid AppID"}
In exchange for two-dimensional code through ticket
After acquiring two-dimensional code ticket, the developer can exchange ticket for two-dimensional code picture. Please note that this interface can be invoked without the login state.
Reminder: Ticket Remember to UrlEncode
Thank you for reading, I hope to help you, thank you for your support for this site!