Detailed graphic and text explanation of how to log in and obtain unionid in WeChat applet

黄舟
Release: 2017-09-13 11:36:34
Original
4434 people have browsed it

This article mainly introduces the relevant information about logging in to WeChat applet to obtain unionid. Friends in need can refer to it

Detailed explanation of logging in to WeChat applet to obtain unionid

First of all, the company has developed mini programs, public account web pages and apps. In the past, openid was used to distinguish users, but openid can only identify the user uniquely in the current mini program or official account. We hope that users can identify users in various products of the company ( For example, the user's uniqueness can be maintained between official accounts, mini programs, and WeChat login in the app. Fortunately, WeChat provides a unionid.

The following is a two-step introduction to the process of obtaining a unionid for a WeChat mini program. .

1. First register the mini program on the WeChat public platform, and then simulate the login process on the mini program.

Note: This is just a simple login process. In practice, the login status needs to be maintained. wx.checkSession() can check whether the login status at this time has expired. If it expires, call wx.login() again, otherwise call wx.getUserInfo() User data will not be obtained.

Note: At this time, the backend server receives the code you sent, and then uses appid and appSecret to request WeChat to get openid and session_key encrypted_data , iv and other data, openid and other information can be obtained by decrypting appId, appSecret. (There is no unionid in the solution at this time, then look at the second step)

2. Next, go to the WeChat development platform Go to bind the development account.

At first I was a little confused about open platforms and public platforms. Later I saw the management center of the development platform and realized that these mobile applications, website applications or public accounts/mini programs If you can bind the same WeChat development platform account, the same user will have the same unionid for different applications under the same WeChat open platform.

It’s probably set up like the picture above, it will take effect immediately (sometimes it will take a few minutes)

The above is the detailed content of Detailed graphic and text explanation of how to log in and obtain unionid in WeChat applet. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template