Realize the function
Generate two-dimensional code, two-dimensional code has some information, scan the two-dimensional code to follow the public number, and then send a message to the user, the message has a small program jump link, and two external links. The jump link of the small program contains the information on the TWO-DIMENSIONAL code. Click the jump link of the small program to enter the small program, and the information on the two-dimensional code will be displayed on the page
Implementation scheme
Access wechat public platform to provide get request interface for token verification and POST request interface with the same name. According to the business scenario is required to be permanent TWO-DIMENSIONAL code, call wechat to generate two-dimensional code interface, pass in the required parameters. After scanning the code, the user will be redirected to the wechat public account attention page, and clicking wechat will push the event to the POST request interface, which will receive the event pushed by wechat and process the reply message.
Reference third-party dependent JAR packages
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-mp</artifactId>
</dependency>
Copy the code
The documentation involved in wechat
Generate qr codeDevelopers.weixin.qq.com/doc/offiacc…
Instructions for accessing wechat public platformDevelopers.weixin.qq.com/doc/offiacc…
Receiving Event Push
Developers.weixin.qq.com/doc/offiacc…
Auto Reply messages (I chose text messages)
Developers.weixin.qq.com/doc/offiacc…
Pay attention to the point
1. Information on the QR code
The original idea is to put a lot of information on the TWO-DIMENSIONAL code, the result is not good, and finally can only put an ID, the interface to obtain THE ID and query the data in the table; In addition, permanent TWO-DIMENSIONAL code only supports the generation of a maximum of 100,000, when using to consider the business scene, MY side about four thousand, so you can use.
2. Passively respond to messages
How to reply to the message, create the corresponding message XML, directly return the message
3. How to reply to the message to have a common link and a small program link
Only text messages are found to be appropriate, with HTML tags for normal links. For links to applets, see the examples below
<a data-miniprogram-appid=" appID of miniprogram "data-miniprogram-path=" miniprogram skip page" >Copy the code