Understand the process of WeChat public account development in 5 minutes

WeChat sdk document link: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_webpage_authorization.html
1. For general development, we will apply for a public account test account for development.
The application steps are: Development=》Development User Settings => Apply for a test account
2. Configure JS secure domain name in the test account
Insert image description here
3. Public account authorization login method
1) Silent authorization (login without user awareness), only openid can be obtained, user information cannot be obtained
2) Non-silent authorization Authorization (requires user authorization), user information can be obtained; the steps are divided into the following steps: the
redirect_uri and state here can be configured, and the others are determined;
Method 1: auth2 fixed authorization address + redirect_uri + business parameter state, Then it is returned to the front end; the front end gets this address and jumps to location.href. After the user agrees to authorize, it gets the code + business parameters and sends them back to the backend. The backend gets the access_token (valid for 2 hours) through the code, and then decrypts it. User information (token mode)
method two: the backend calls the WeChat address (auth2 fixed authorization address), and then the backend directly obtains the code (session mode)

4. For usage of other SDK functions, please read the documentation first.

Pitfalls encountered:
1. Vue's hash mode development WeChat sharing: exceptions will occur when sharing between ios and Android. When ios is shared, it will always be the home page instead of the current page. To deal with this: make an intermediate page to process the sharing
; . . Will continue to record later

Guess you like

Origin blog.csdn.net/qq_37174991/article/details/113997449