uniapp+php使用阿里云进行人脸实名认证采坑笔记
一、开通阿里云实人认证
地址:https://www.aliyun.com/product/cloudauth
然后在控制台接入场景设置中添加一个场景,注意,这个场景id后面编程要用到。
二、下载uniapp的阿里云实人认证的原生插件,导入到uniapp项目中。
具体教程:https://help.aliyun.com/zh/id-verification/financial-grade-id-verification/uniapp-integration
注意原生插件打包的时候不能同时选择uniapp内置的实人认证模块,否则打包会报错:
三、编写服务端阿里云实人认证php代码
composer 安装cloudauth库
composer require alibabacloud/cloudauth-20200618 1.0.5
<?php require("vendor/autoload.php"); use AlibabaCloud\Credentials\Credential; use AlibabaCloud\SDK\Cloudauth\V20200618\Cloudauth; use AlibabaCloud\Tea\Utils\Utils; use AlibabaCloud\Tea\Exception\TeaError; use AlibabaCloud\Tea\Rpc\Rpc\Config; use AlibabaCloud\SDK\Cloudauth\V20200618\Models\InitSmartVerifyRequest; use AlibabaCloud\SDK\Cloudauth\V20200618\Models\InitSmartVerifyResponse; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; $request = new InitSmartVerifyRequest([ // 请输入场景ID。 "sceneId" => 第一步添加获得的场景值, "outerOrderNo" => time(), // 证件类型,固定值。 "mode" => "MARKET_SAFE", "ocr" => "F", "certType" => "IDENTITY_CARD", "certName" => "姓名", "certNo" => "身份证号码", // MetaInfo环境参数,需要通过客户端SDK获取。 "metaInfo" => '{"zimVer":"3.0.0","appVersion": "1","bioMetaInfo": "4.1.0:11501568,0", "appName": "com.aliyun.cloudauth","deviceType": "ios","osVersion": "iOS 10.3.2","apdidToken": "","deviceModel": "iPhone9,1"}', "mobile" => "<130xxxxxxxx>", // "ip" => "<114.xxx.xxx.xxx>", // "userId" => "<12345xxxx>", // "callbackUrl" => "<https://www.aliyundoc.com>", // "callbackToken" => "<xxxxxxx>" ]); // 推荐,支持服务自动路由。 $response = initSmar...
点击查看剩余70%
网友评论0