In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to use WeChat Mini Programs getPhoneNumber to quickly obtain users' mobile phone number components". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Description
To obtain the mobile number bound by Wechat users, you need to call the API login.
Because it needs to be triggered actively by the user to initiate the API to obtain the mobile phone number, this function is not called by API, but is triggered by the click of the component.
Note: this API is currently open to non-individual developers and has completed the verification of Mini Program. Use with caution. If users report too many reports or are found to be using it in unnecessary scenarios, Wechat has the right to permanently reclaim the permission of the Mini Program API.
Usage
The value of the component open-type needs to be set to getPhoneNumber. When the user clicks and agrees, the encrypted data returned by the Wechat server can be obtained through the bindgetphonenumber event callback, and then decrypted with session_key and app_id on the third-party server to obtain the mobile phone number.
Be careful
Calling wx.login login in the callback may refresh the login state. At this time, the sessionKey that the server uses code for is not the sessionKey used for encryption, which causes the decryption to fail. It is recommended that developers perform login; in advance or use checkSession to check login status in callback to prevent login from refreshing login status.
Example Page ({getPhoneNumber: function (e) {console.log (e.detail.errMsg) console.log (e.detail.iv) console.log (e.detail.encryptedData)}) returns parameters indicating the type of parameters indicating the encrypted data of encryptedDataString's complete user information, including sensitive data. For more information, please see the initial vector of encrypted data decryption algorithm ivString encryption algorithm, and encrypted data decryption algorithm for details.
The decrypted encryptedData has the following json structure. For more information, please see the encrypted data decryption algorithm.
{"phoneNumber": "13580006666", "purePhoneNumber": "13580006666", "countryCode": "86", "watermark": {"appid": "APPID", "timestamp": TIMESTAMP}} Parameter type description phoneNumberString user bound mobile phone number (foreign mobile phone number will have an area code) purePhoneNumberString mobile phone code without area code countryCodeString area code "how to quickly obtain a user's mobile phone number component with WeChat Mini Programs getPhoneNumber" is introduced here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.