WeChat Mini Program API User Information
wx.getUserInfo(OBJECT)
The WeChat applet needs to call the wx.login interface first to obtain user information.
OBJECT parameter description:
success Return parameter description:
Sample code:
wx.getUserInfo({ success: function(res) { var userInfo = res.userInfo var nickName = userInfo.nickName var avatarUrl = userInfo.avatarUrl var gender = userInfo.gender //性别 0:未知、1:男、2:女 var province = userInfo.province var city = userInfo.city var country = userInfo.country } })
encryptedData will be the following json structure after decryption. For details, please refer to the encrypted data decryption algorithm
{ "openId": "OPENID", "nickName": "NICKNAME", "gender": GENDER, "city": "CITY", "province": "PROVINCE", "country": "COUNTRY", "avatarUrl": "AVATARURL", "unionId": "UNIONID", "watermark": { "appid":"APPID", "timestamp":TIMESTAMP } }
UnionID mechanism description:
If the developer has multiple mobile applications, website applications, and public accounts (including Mini program), the user's uniqueness can be distinguished by unionid, because as long as there are mobile applications, website applications and public accounts (including mini programs) under the same WeChat open platform account, the user's unionid is unique. In other words, for the same user, the unionid is the same for different applications under the same WeChat open platform.
WeChat Open Platform Binding Mini Program Process
Prerequisite: WeChat Open Platform account must have completed developer qualification certification
Developer Qualification Certification Process :
Log in to WeChat Open Platform (open.weixin.qq.com) – Account Center – Developer Qualification Certification
##Binding Process:Log in to WeChat Open Platform (open.weixin.qq.com) - Management Center - Public Account - Bind Public Account
- tip
:
wx.getUserInfoThe interface requires user authorization, please be compatible with the scenario where the user refuses authorization.