[WeChat Public Account] 16. SpringBoot integrates WxJava to generate a QR code with parameters

In order to meet the needs of scenarios such as user channel promotion analysis and user account binding, the public platform provides an interface for generating QR codes with parameters. Using this interface, multiple QR codes with different scene values ​​can be obtained. After the user scans, the Official Account can receive event pushes.

1. Two types

  1. Temporary QR codes have an expiration time, which can be set to expire after 30 days (that is, 2592000 seconds) after the QR code is generated at the longest, but a large number can be generated. Temporary QR codes are mainly used in business scenarios that do not require permanent storage of QR codes, such as account binding
  2. Permanent QR codes have no expiration time, but the number is small (currently up to 100,000). Permanent QR codes are mainly used in scenarios such as account binding and user source statistics.

2. Two events

When the user scans the QR code with scene value, the following two events may be pushed:

  1. If the user has not followed the official account, the user can follow the official account. After following the official account, WeChat will push the attention event with scene value to the developer.
  2. If the user has followed the official account, it will automatically enter the session after the user scans, and WeChat will also push the scan event with scene value to the developer.

3. Create a QR code ticket

Each time you create a QR code ticket, you need to provide a parameter (scene_id) set by the developer, and introduce the process of creating a QR code ticket for a temporary QR code and a permanent QR code respectively.

  1. temporary ticket
// 临时ticket
WxMpQrCodeTicket tempTicket = wxMpService

Guess you like

Origin blog.csdn.net/qq_40065776/article/details/131776319