APPID:wx2365bd3927cb4d23
服务端验证时的错误信息:
{"errcode":84006,"errmsg":"name or id_card_number empty hint: [_02W0a09883230][2023-10-20 15:46:28] rid: 65323054-6ddb04d2-0bdbf0ab"}"
小程序端代码
//小程序端人脸核身
let res = await wepy.wx.startFacialRecognitionVerify({
name:_this.name,
idCardNumber:_this.card,
})
if(res.errCode !== 0){
Dialog.alert({
title: '错误',
message: res.errmsg,
}).then(() => {
// on close
})
return
}
//后端人脸核身
let resp = await request('authorizations/facial', {
method: 'post',
data: {
'name':_this.name,
'card':_this.card,
'verify_result':res.verifyResult
}
})
console.log(resp)
服务端代码(PHP easywecht 6 版本)
public function facial(Request $request){
$validator = Validator::make($request->all(), [
'name' => 'required|string',
'card' => 'required|string',
'verify_result' => 'required|string',
]);
if ($validator->fails()) {
return $this->errorBadRequest('参数错误');
}
$app = new Application(config('wechat.mini_program'));
$api = $app->getClient();
$response = $api->postJson('/cityservice/face/identify/getuseridkey', [
"verify_result" => $request->verify_result,
]);
dd($response->getContent());
}
验证核身结果的接口是下面这个/cityservice/face/identify/getinfo,可以仔细看下文档https://developers.weixin.qq.com/community/business/doc/000442d352c1202bd498ecb105c00d