支付宝刷脸认证

2019/08/19 18:12
阅读数 26

去支付宝下载sdk  这里引用我就不多说了

 

Loader::import('ali.wappay.service.AlipayTradeService',EXTEND_PATH,'.php');
Loader::import('ali.wappay.buildermodel.AlipayTradeWapPayContentBuilder',EXTEND_PATH,'.php');

//扫脸身份验证
public function idyanz(){
$idnumber =input('idnumber');//身份证号
$name = input('name');//姓名
Loader::import('ali.aop.request.AlipayTradeAppPayRequest',EXTEND_PATH,'.php');
Loader::import('ali.aop.AopClient',EXTEND_PATH,'.php');
Loader::import('ali.aop.request.AlipayUserCertifyOpenInitializeRequest ',EXTEND_PATH,'.php');
Loader::import('ali.aop.request.AlipayUserCertifyOpenCertifyRequest ',EXTEND_PATH,'.php');
$aop = new \AopClient ();
$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = 'appid';
$aop->rsaPrivateKey = '公钥';
$aop->alipayrsaPublicKey='私钥';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$request = new \AlipayUserCertifyOpenInitializeRequest ();
$str = date('Ymd') . str_pad(mt_rand(1, 99999), 5, '0', STR_PAD_LEFT);
$data = array(
'outer_order_no'=>$str,
'biz_code'=>'FACE',
'identity_param'=>array(
'identity_type'=>'CERT_INFO',
'cert_type'=>'IDENTITY_CARD',
'cert_name'=>$name,
'cert_no'=>$idnumber,
),
'merchant_config'=>array(
'return_url'=>'http://www.yuming.cn/index?id='.$id['id'],
),
);
$request->setBizContent(json_encode($data));
$result = $aop->execute ($request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;
if(!empty($resultCode)&&$resultCode == 10000){
$certify_id = $result->$responseNode->certify_id;
$requests = new \AlipayUserCertifyOpenCertifyRequest();
$datas =array(
'certify_id'=>$certify_id,
);
$requests->setBizContent(json_encode($datas));
$results = $aop->pageExecute ( $requests);
return $results;
}
}

 


//查询扫脸是否验证
public function shualia($id){
Loader::import('ali.aop.request.AlipayTradeAppPayRequest',EXTEND_PATH,'.php');
Loader::import('ali.aop.AopClient',EXTEND_PATH,'.php');
Loader::import('ali.aop.request.AlipayUserCertifyOpenInitializeRequest ',EXTEND_PATH,'.php');
Loader::import('ali.aop.request.AlipayUserCertifyOpenQueryRequest ',EXTEND_PATH,'.php');
$aop = new \AopClient ();
$certify_id=DB::table('certifyid')->where(array('uid'=>$id))->order('id desc')->find();

$aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
$aop->appId = '4444';
$aop->rsaPrivateKey = '公钥';
$aop->alipayrsaPublicKey='私钥';
$aop->apiVersion = '1.0';
$aop->signType = 'RSA2';
$aop->postCharset='utf-8';
$aop->format='json';
$request = new \AlipayUserCertifyOpenQueryRequest ();
$datas =array(
'certify_id'=>$certify_id['certifyid'],
);
$request->setBizContent(json_encode($datas));
$result = $aop->execute ( $request);
$responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
$resultCode = $result->$responseNode->code;

if(!empty($resultCode)&&$resultCode == 10000){
$resultpassed = $result->$responseNode->passed;

if($resultpassed == 'T'){
//认证成功业务逻辑
}
}
}

 基本上改一改就能用支付宝扫脸认证了 里边引用的就都是支付宝扫码的sdk了

 

  

  

 

展开阅读全文
php
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
在线直播报名
返回顶部
顶部