Loading…

How to use the "Face Core" function of WeChat Mini Program

Face verification is face recognition, which can realize real-name recognition or personal consistency verification after real-name authentication. As shown below: ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1627834341923-334ef38b-0d6c-4208-b4b3-af1782fa6a8b.png) ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1627834352041-d43f9f88-ce22-40d1-9134-8469aaec14b3.png) #Official documentation [https://developers.weixin.qq.com/community/minihome/doc/000442d352c1202bd498ecb105c00d](https://developers.weixin.qq.com/community/minihome/doc/000442d352c1202bd498ecb105c00d) [https://docs.qq.com/doc/DTFB0YWFIdGV6amly](https://docs.qq.com/doc/DTFB0YWFIdGV6amly) Please follow the guidelines in the above document to apply for the "Face Verification" function. Please pay attention to the application restrictions for this function and determine whether you meet the requirements for activating this function. #Usage scenarios ## 1. The user has been authenticated by real name and can verify himself by scanning his face. For example, if you have already had business logic or integrated a real-name authentication interface, and have allowed users to perform real-name authentication, but you cannot ensure that the user used his or her own ID card for real-name authentication (for example, he took someone else's ID card information for real-name authentication), then you can use this function to verify that it is done by you. ### Mini program code ```javascript wx.startFacialRecognitionVerify({ name: 'name', idCardNumber: 'ID card number', success: res => { console.log(res) }, fail: err => { console.error(err) }, }) ``` After the authentication passes, the res information will be output. If the authentication fails, the err information will be output. ### Call the interface to complete the verification After the authentication is successful, call the face core interface of "apifm" to complete the verification: ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1627834850229-0febbf08-4efe-4759-a7d7-e25448014da1.png) The content parameter needs to be passed the ** returned by the WeChat API in the previous step. res.verifyResult** ## 2. Complete real-name authentication and face-swiping authentication simultaneously For users who have not done real-name authentication, real-name authentication + face-swiping authentication can be completed in one step. ### Submit identity information ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1627834979873-c039ec29-4b3f-4200-941d-a0cd70304bc9.png) Call the "apifm" face verification interface to submit name and ID card, allowing users to actively fill in their name and ID number, and then click Next to perform face verification. ### Mini program code ```javascript wx.startFacialRecognitionVerify({ userIdKey: '434ceff650264ba6b2e19cd68f08c818', success: res => { console.log(res) }, fail: err => { console.error(err) }, }) ``` Here userIdKey is the data returned by the interface in the previous step. ### Call the interface to complete the verification After the authentication is successful, call the face core interface of "apifm" to complete the verification: ![](https://dcdn.it120.cc/yuque/0/2021/png/572726/1627834850229-0febbf08-4efe-4759-a7d7-e25448014da1.png) The content parameter needs to be passed the ** returned by the WeChat API in the previous step. res.verifyResult** **** # How to determine whether the real name is real and whether the face is swiped Read user details interface, 2 new attributes are added to return: + isIdcardCheck true means that the real-name authentication has been passed, false means that the real-name authentication has not been passed. + isFaceCheck true means that the face-swiping authentication has been passed, false means that the face-swiping authentication has not been passed.