1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- // 实名认证用的
- namespace app\api\controller;
- use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
- use \Exception;
- use AlibabaCloud\Tea\Exception\TeaError;
- use AlibabaCloud\Tea\Utils\Utils;
- use AlibabaCloud\SDK\Cloudauth\V20190307\Models\DescribeFaceVerifyRequest;
- use Darabonba\OpenApi\Models\Config;
- use AlibabaCloud\SDK\Cloudauth\V20190307\Models\InitFaceVerifyRequest;
- use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
- $path = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
- if (file_exists($path)) {
- require_once $path;
- }
- class Certification {
- /**
- * 使用AK&SK初始化账号Client
- * @param string $accessKeyId
- * @param string $accessKeySecret
- * @return Cloudauth Client
- */
- public static function createClient($accessKeyId, $accessKeySecret){
- $config = new Config([
- // 您的 AccessKey ID
- "accessKeyId" => $accessKeyId,
- // 您的 AccessKey Secret
- "accessKeySecret" => $accessKeySecret,
- ]);
- // 访问的域名
- $config->endpoint = "cloudauth.aliyuncs.com";
- return new Cloudauth($config);
- }
- /**
- * @param string[] $args
- * @return void
- */
- public static function main($certName,$certNo,$metaInfo,$ReturnUrl){
- $client = self::createClient("LTAI5tMVT8vs7B1CApqhEgBo", "ESDiEM6zED1vyCMoGc9j5gZ9hWIXkP");
- $initFaceVerifyRequest = new InitFaceVerifyRequest([
- "sceneId" => '1000006090',
- "outerOrderNo" => get32Str(),
- // 要接入的认证方案。
- "productCode" => "ID_PRO",
- "certType" => "IDENTITY_CARD",
- "certName" => $certName,
- "certNo" => $certNo,
- // MetaInfo环境参数,需要通过客户端SDK获取。
- "metaInfo" => $metaInfo,
- "returnUrl" => $ReturnUrl,
- ]);
- $runtime = new RuntimeOptions([]);
- try {
- // 复制代码运行请自行打印 API 的返回值
- $res = $client->initFaceVerifyWithOptions($initFaceVerifyRequest, $runtime);
- return $res;
- } catch (Exception $error) {
- if (!($error instanceof TeaError)) {
- $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
- }
- // 如有需要,请打印 error
- Utils::assertAsString($error->message);
- return '';
- }
- }
- /**
- * @param string[] $args
- * @return void
- */
- public static function check($CertifyId){
- $client = self::createClient("LTAI5tAVV4VEU4vFVqpune1Q", "IMRENgb7kQsjLXfJ33aCyeTLeNj9DH");
- $describeFaceVerifyRequest = new DescribeFaceVerifyRequest([
- 'sceneId' => '1000004552',
- 'certifyId' => $CertifyId,
- ]);
- $runtime = new RuntimeOptions([]);
- try {
- // 复制代码运行请自行打印 API 的返回值
- $rs = $client->describeFaceVerifyWithOptions($describeFaceVerifyRequest, $runtime);
- return $rs;
- }
- catch (Exception $error) {
- if (!($error instanceof TeaError)) {
- $error = new TeaError([], $error->getMessage(), $error->getCode(), $error);
- }
- // 如有需要,请打印 error
- Utils::assertAsString($error->message);
- return false;
- }
- }
- }
|