# Mobile Phone Number Quick Verification Component

The ability is designed to help developers to initiate a mobile phone number application to users, and only after the user's consent, developers can obtain a mobile phone number verified by the platform, and then provide users with corresponding services.

The following is the old version of the component use guide, note that the use of the old version of the components, you need to first callwx.loginInterface. It is recommended that developers use the new version of the component to enhance Mini Program security. detailsNew Component Usage Guide

Because the user needs to actively trigger to initiate rapid verification of the phone number, the function is not API To call, with button Component's click to trigger.

Be careful

  • 1. At present, the interface is aimed at non-individual developers and has completed the certification of Mini programs (excluding overseas entities). It needs to be used with caution, if the user reports more or is found to be used in unnecessary scenarios, WeChat has the right to permanently recover the interface permissions of the Mini Program.
  • 2. When this ability is used, the user can choose to bind the number, or add the number independently. The platform will verify the number, but it does not guarantee real-time verification.
  • 3. Ask developers to judge and choose whether to use according to the needs of business scenarios, and consider adding other security verification methods if necessary.

# Methods of Use

The need to button assembly open-type The value of the getPhoneNumber, when the user clicks and agrees, it can be accessed by bindgetphonenumber Event callback to get the encrypted data returned to the WeChat server, Then combine it with a third-party server session_key as well as app_id Decrypt it to get the phone number.

# Note

Called in the callback wx.login Login, may refresh the login state. At this time the server uses Code In exchange for sessionKey Not used in encryption. SessionKey, causing decryption to fail. Developers are advised to proceed in advance LoginOr use it first in the callback checkSession Perform a login state check to avoid Login Refresh the login state.

# Code Examples

<button open-type="getPhoneNumber"  bindgetphonenumber="getPhoneNumber" ></button>
Page({
  getPhoneNumber (e) {
    console.log(e.detail.errMsg)
    console.log(e.detail.iv )
    console.log(e.detail.encryptedData)
  }
})

# Return Parameter Dxplaination

parameter type Introductions Minimum version
encryptedData String Encrypted data for complete user information, including sensitive data, as detailed in[Encryption data decryption algorithm]((signature#Encryption data decryption algorithm))
iv String The initial vector of the encryption algorithm, see in detail[Encryption data decryption algorithm]((signature#Encryption data decryption algorithm))
cloudID string The Cloud for Sensitive Data ID, opening the cloud development of Mini programs will return, can be directly accessed through the cloud call open data, seeCloud Call Direct Access to Open Data Base library 2.8.0

The resulting open data are as follows json Structure:

{
    "phoneNumber": "13580006666",
    "purePhoneNumber":  "13580006666",
    "countryCode": "86",
    "watermark":
    {
        "appid":"APPID" 
        "timestamp": TIMESTAMP
    }
}
parameter type Introductions
phoneNumber String The mobile phone number bound by the user (foreign mobile phone numbers will have area codes)
purePhoneNumber String A cell phone number without an area code
countryCode String area code