日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

SDK調用示例

本文介紹在金融級實人認證方案App(SDK)接入場景下,通過SDK調用服務端OpenAPI的示例流程。

服務端需要集成的OpenAPI

步驟一:開通服務

在使用金融級實人認證服務之前,您需要開通服務。具體操作,請參見開通金融級實人認證服務

步驟二:創建RAM用戶并授權

如果您需要精細化的服務訪問管理。在集成SDK前,您需要創建一個RAM用戶用于調用SDK的服務接口,獲取關聯的OpenAPI訪問憑據,并授予訪問云上資源的權限。如何創建和授權RAM用戶,以及如何生成用于調用服務的AccessKey,請參見授權RAM用戶訪問服務

步驟三:添加認證場景

認證場景指您的用戶使用金融級實人認證服務完成用戶實人認證的不同場景,例如,登錄、支付等。您可以添加一個或多個場景,并為不同的場景配置不同的認證方案。調用InitFaceVerify發起認證請求時,需要傳輸認證場景ID。如何添加認證場景并獲取認證場景ID, 請參見添加認證場景

說明

在添加認證場景時,您可以授權阿里云訪問指定OSS存儲空間,用于存儲認證的資料圖片。具體操作,請參見授權金融級實人認證訪問OSS存儲空間

步驟四:集成SDK并編輯寫代碼

服務接入點

目前支持的接入地域如下表所示。

重要

建議您參考本文示例代碼,配置主備地域Endpoint。在主Endpoint發生故障時可以自動切換到備用Endpoint,保證系統的持續可用性。

地域

服務地址

VPC地址

全局接入地址

華東2(上海)

IPv4:cloudauth.cn-shanghai.aliyuncs.com

cloudauth-vpc.cn-shanghai.aliyuncs.com

  • IPv4:cloudauth.aliyuncs.com

  • IPv6:cloudauth-dualstack.aliyuncs.com

IPv6:cloudauth-dualstack.aliyuncs.com

華北2(北京)

IPv4:cloudauth.cn-beijing.aliyuncs.com

cloudauth-vpc.cn-beijing.aliyuncs.com

IPv6:cloudauth-dualstack.cn-beijing.aliyuncs.com

SDK安裝與源碼下載

您可根據業務實際的技術選型,選擇合適的SDK語言進行集成。

支持語言

SDK下載地址

Github源碼地址

Java

下載Java SDK

Alibaba Cloud Green SDK for Java

Python

下載Python SDK

Alibaba Cloud Green SDK for Python

Typescript

下載TypeScript SDK

Alibaba Cloud Green SDK for Typescript

Go

下載Go SDK

Alibaba Cloud Green SDK for Go

PHP

下載PHP SDK

Alibaba Cloud Green SDK for PHP

C#

下載C# SDK

Alibaba Cloud Green SDK for C#

C++

下載C++ SDK

Alibaba Cloud Green SDK for C++

在環境變量中配置AccessKey

重要

集成前請確認您已獲取AccessKey,并已配置環境變量。具體操作,請參見:

編寫代碼

下面以Java語言為例介紹。

  1. 在pom.xml中添加如下依賴,即可在Maven工程中使用SDK。

    • Java SDK依賴。以下依賴版本使用了最新版本,建議在測試穩定后固定版本號,SDK版本和示例請參見最新依賴版本

    • 配置接口前需要將AccessKey配置到環境變量中。如何配置環境變量,請參見在Linux、macOS和Windows系統配置環境變量

      <dependency>
       <groupId>com.aliyun</groupId>
       <artifactId>cloudauth20190307</artifactId>
      <!--建議測試穩定后固定版本號--> <version>LATEST</version> 
      </dependency>
  2. 示例代碼。

    • InitFaceVerify接口調用示例

      import java.util.Arrays;
      import java.util.List;
      
      import com.aliyun.cloudauth20190307.Client;
      import com.aliyun.cloudauth20190307.models.*;
      import com.aliyun.teaopenapi.models.Config;
      import com.aliyun.teautil.models.RuntimeOptions;
      
      public class InitFaceVerify {
      
          public static void main(String[] args) throws Exception {
      
              InitFaceVerifyRequest request = new InitFaceVerifyRequest();
              // 請輸入場景ID+L。
              request.setSceneId(0L);
              // 設置商戶請求的唯一標識。
              request.setOuterOrderNo("xxxx");
              // 認證方案。
              request.setProductCode("ID_PRO");
              // 模式。
              request.setModel("LIVENESS");
              request.setCertType("IDENTITY_CARD");
              request.setCertName("張先生");
              request.setCertNo("xxxx");
              // MetaInfo環境參數。
              request.setMetaInfo("{}");
              //request.setMobile("130xxxxxxxx");
              //request.setIp("114.xxx.xxx.xxx");
              //request.setUserId("12345xxxx");
              //request.setCallbackUrl("https://www.aliyundoc.com");
              //request.setCallbackToken("xxxxx");
              // 如需開啟個人信息加密傳輸。
              //request.setEncryptType("SM2");
              //request.setCertName("BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==");
              //request.setCertNo("BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg==");
      
              // 推薦,支持服務路由。
              InitFaceVerifyResponse response = initFaceVerifyAutoRoute(request);
      
              // 不支持服務自動路由。
              //InitFaceVerifyResponse response = initFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
      
              response.getBody().getRequestId();
              response.getBody().getResultObject().getCertifyId();
              System.out.println(response.getBody().getRequestId());
              System.out.println(response.getBody().getCode());
              System.out.println(response.getBody().getMessage());
              System.out.println(response.getBody().getResultObject() == null ? null
                      : response.getBody().getResultObject().getCertifyId());
          }
      
          private static InitFaceVerifyResponse initFaceVerifyAutoRoute(InitFaceVerifyRequest request) {
              // 第一個為主區域Endpoint,第二個為備區域Endpoint。
              List<String> endpoints = Arrays.asList("cloudauth.cn-shanghai.aliyuncs.com", "cloudauth.cn-beijing.aliyuncs.com");
              InitFaceVerifyResponse lastResponse = null;
              for (int i=0; i<endpoints.size(); i++) {
                  try {
                      InitFaceVerifyResponse response = initFaceVerify(endpoints.get(i), request);
                      lastResponse = response;
      
                      // 服務端錯誤,切換到下個區域調用。
                      if(response != null){
                          if(500 == response.getStatusCode()){
                              continue;
                          }
                          if(response.getBody() != null){
                              if("500".equals(response.getBody().getCode())){
                                  continue;
                              }
                          }
                      }
      
                      // 正常返回
                      return lastResponse;
                  }catch (Exception e) {
                      e.printStackTrace();
                      if(i == endpoints.size()-1){
                          throw new RuntimeException(e);
                      }
                  }
              }
      
              return lastResponse;
          }
      
          private static InitFaceVerifyResponse initFaceVerify(String endpoint, InitFaceVerifyRequest request)
                  throws Exception {
              // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
              // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
              // 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。如何配置環境變量,請參見http://bestwisewords.com/document_detail/378657.html。
              com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
              Config config = new Config();
              config.setCredential(credentialClient);
              config.setEndpoint(endpoint);
              // 設置http代理。
              //config.setHttpProxy("http://xx.xx.xx.xx:xxxx");
              // 設置https代理。
              //config.setHttpsProxy("https://xx.xx.xx.xx:xxxx");
              Client client = new Client(config);
      
              // 創建RuntimeObject實例并設置運行參數。
              RuntimeOptions runtime = new RuntimeOptions();
              runtime.readTimeout = 10000;
              runtime.connectTimeout = 10000;
      
              return client.initFaceVerifyWithOptions(request, runtime);
          }
      
      }
    • DescribeFaceVerify接口調用示例

      import java.util.Arrays;
      import java.util.List;
      
      import com.aliyun.cloudauth20190307.Client;
      import com.aliyun.cloudauth20190307.models.DescribeFaceVerifyRequest;
      import com.aliyun.cloudauth20190307.models.DescribeFaceVerifyResponse;
      import com.aliyun.teaopenapi.models.Config;
      import com.aliyun.teautil.models.RuntimeOptions;
      
      public class DescribeFaceVerify {
      
          public static void main(String[] args) throws Exception {
      
              // 通過以下代碼創建API請求并設置參數。
              DescribeFaceVerifyRequest request = new DescribeFaceVerifyRequest();
              // 請輸入場景ID+L。
              request.setSceneId(0L);
      
              request.setCertifyId("xxxx");
      
              // 推薦,支持服務路由。
              DescribeFaceVerifyResponse response = describeFaceVerifyAutoRoute(request);
      
              // 不支持服務自動路由。
              //DescribeFaceVerifyResponse response = describeFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
      
              System.out.println(response.getBody().getRequestId());
              System.out.println(response.getBody().getCode());
              System.out.println(response.getBody().getMessage());
              System.out.println(
                      response.getBody().getResultObject() == null ? null : response.getBody().getResultObject().getPassed());
              System.out.println(
                      response.getBody().getResultObject() == null ? null : response.getBody().getResultObject().getSubCode());
              System.out.println(
                      response.getBody().getResultObject() == null ? null
                              : response.getBody().getResultObject().getIdentityInfo());
              System.out.println(
                      response.getBody().getResultObject() == null ? null
                              : response.getBody().getResultObject().getDeviceToken());
              System.out.println(
                      response.getBody().getResultObject() == null ? null
                              : response.getBody().getResultObject().getMaterialInfo());
          }
      
          private static DescribeFaceVerifyResponse describeFaceVerifyAutoRoute(DescribeFaceVerifyRequest request) {
              // 第一個為主區域Endpoint,第二個為備區域Endpoint。
              List<String> endpoints = Arrays.asList("cloudauth.cn-shanghai.aliyuncs.com", "cloudauth.cn-beijing.aliyuncs.com");
              DescribeFaceVerifyResponse lastResponse = null;
              for (int i = 0; i < endpoints.size(); i++) {
                  try {
                      DescribeFaceVerifyResponse response = describeFaceVerify(endpoints.get(i), request);
                      lastResponse = response;
      
                      // 服務端錯誤,切換到下個區域調用。
                      if (response != null) {
                          if (500 == response.getStatusCode()) {
                              continue;
                          }
                          if (response.getBody() != null) {
                              if ("500".equals(response.getBody().getCode())) {
                                  continue;
                              }
                          }
                      }
      
                      return lastResponse;
                  } catch (Exception e) {
                      if (i == endpoints.size() - 1) {
                          throw new RuntimeException(e);
                      }
                  }
              }
      
              return lastResponse;
          }
      
          private static DescribeFaceVerifyResponse describeFaceVerify(String endpoint, DescribeFaceVerifyRequest request)
                  throws Exception {
              // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
              // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
              //本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。如何配置環境變量,請參見http://bestwisewords.com/document_detail/378657.html。
              com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
              Config config = new Config();
              config.setCredential(credentialClient);
              config.setEndpoint(endpoint);
              // 設置http代理。
              //config.setHttpProxy("http://xx.xx.xx.xx:xxxx");
              // 設置https代理。
              //config.setHttpsProxy("http://xx.xx.xx.xx:xxxx");
              Client client = new Client(config);
      
              // 創建RuntimeObject實例并設置運行參數。
              RuntimeOptions runtime = new RuntimeOptions();
              runtime.readTimeout = 10000;
              runtime.connectTimeout = 10000;
      
              return client.describeFaceVerifyWithOptions(request, runtime);
          }
      }

其他支持語言示例

PHP

InitFaceVerify接口調用示例

<?php
namespace AlibabaCloud\SDK\Sample\Verify\Id;

use AlibabaCloud\Credentials\Credential; 
use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\InitFaceVerifyRequest;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\InitFaceVerifyResponse;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Exception;

use Darabonba\OpenApi\Models\Config;

class InitFaceVerify
{

    /**
     * createClient
     * @param string $endpoint
     * @return Cloudauth
     */
    public static function createClient(string $endpoint): Cloudauth
    {
         // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
        // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
        // 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
        $credential = new Credential([]);
        $config = new Config([
			 // 使用credential配置憑證
    		"credential" => $credential,
            // 設置HTTP代理。
            // "httpProxy" => "<http://xx.xx.xx.xx:xxxx>",
            // 設置HTTPS代理
            // "httpsProxy" => "<https://xx.xx.xx.xx:xxxx>",
            "endpoint" => $endpoint

        ]);
        return new Cloudauth($config);
    }

    /**
     * main
     * @return void
     * @throws Exception
     */
    public static function main()
    {
        $request = new InitFaceVerifyRequest([
            // 請輸入場景ID。
            "sceneId" => 0,
            "outerOrderNo" => "<商戶請求的唯一標識>",
            // 要接入的認證方案。
            "productCode" => "ID_PRO",
            // 要進行活體檢測的類型。
            "model" => "LIVENESS",
            "certType" => "IDENTITY_CARD",
            "certName" => "<xxx>",
            "certNo" => "<xxx>",
            // MetaInfo環境參數,需要通過客戶端SDK獲取。
            "metaInfo" => '{"zimVer":"3.0.0","appVersion": "1","bioMetaInfo": "4.1.0:11501568,0","appName": "com.aliyun.antcloudauth","deviceType": "ios","osVersion": "iOS 10.3.2","apdidToken": "","deviceModel": "iPhone9,1"}',
            // "mobile" => "<xxx>",
            // "ip" => "<114.xxx.xxx.xxx>",
            // "userId" => "<12345xxxx>",
            // "callbackUrl" => "<https://www.aliyundoc.com>",
            // "callbackToken" => "<xxxxxxx>",
            // 如需開啟個人信息加密傳輸。
            // "encryptType" => "SM2",
            // "certName" => "BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==",
            // "certNo" => "BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg=="
        ]);

        // 推薦,支持服務路由。
        $response = self::initFaceVerifyAutoRoute($request);
        // 不支持服務自動路由。
        // $response = self::initFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", $request);
        var_dump($response->body->requestId);
        var_dump($response->body->code);
        var_dump($response->body->message);
        var_dump($response->body->resultObject->certifyId);
    }

    /**
     * initFaceVerifyAutoRoute
     * @param InitFaceVerifyRequest $request
     * @return InitFaceVerifyResponse|null
     */
    public static function initFaceVerifyAutoRoute(InitFaceVerifyRequest $request): ?InitFaceVerifyResponse
    {
        $endpoints = [
            "cloudauth.cn-shanghai.aliyuncs.com",
            "cloudauth.cn-beijing.aliyuncs.com"
        ];
        foreach ($endpoints as $endpoint) {
            try {
                $response = self::initFaceVerify($endpoint, $request);
                if (Utils::equalNumber(500, $response->statusCode)) {
                    continue;
                }
                if(Utils::equalString("500", $response->body->code)){
                    continue;
                }
                return $response;
            } catch (Exception $err) {
                var_dump($err -> getCode());
                var_dump($err -> getMessage());
            }
        }
        return null;
    }

    /**
     * initFaceVerify
     * @param string $endpoint
     * @param InitFaceVerifyRequest $request
     * @return InitFaceVerifyResponse
     */
    public static function initFaceVerify(string $endpoint, InitFaceVerifyRequest $request): InitFaceVerifyResponse
    {
        $client = self::createClient($endpoint);
        // 創建RuntimeObject實例并設置運行參數。
        $runtime = new RuntimeOptions([]);
        $runtime->readTimeout = 10000;
        $runtime->connectTimeout = 10000;
        return $client->initFaceVerifyWithOptions($request, $runtime);
    }
}

$path = __DIR__ . \DIRECTORY_SEPARATOR . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
InitFaceVerify::main();

DescribeFaceVerify接口調用示例

<?php

namespace AlibabaCloud\SDK\Sample\Verify\Id;

use AlibabaCloud\Credentials\Credential; 
use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\DescribeFaceVerifyRequest;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\DescribeFaceVerifyResponse;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use \Exception;

use Darabonba\OpenApi\Models\Config;

class DescribeFaceVerify {

    /**
     * createClient
     * @param string $endpoint
     * @return Cloudauth
     */
    public static function createClient(string $endpoint): Cloudauth
    {
        // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
        // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
        // 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
        $credential = new Credential([]);
        $config = new Config([
			// 使用credential配置憑證
    		"credential" => $credential,
            // 設置HTTP代理。
            // "httpProxy" => "<http://xx.xx.xx.xx:xxxx>",
            // 設置HTTPS代理
            // "httpsProxy" => "<https://xx.xx.xx.xx:xxxx>",
            "endpoint" => $endpoint

        ]);
        return new Cloudauth($config);
    }

    /**
     * main
     * @return void
     */
    public static function main(){
        $request = new DescribeFaceVerifyRequest();
        // 場景ID。
        $request->sceneId=0;
        // 認證ID。
        $request->certifyId="<xxx>";
        // 推薦,支持服務路由。
        $response = self::describeFaceVerifyAutoRoute($request);
        // 不支持服務自動路由。
        // $response = self::describeFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", $request);
        var_dump($response->body->requestId);
        var_dump($response->body->code);
        var_dump($response->body->message);
        var_dump($response->body->resultObject->passed);
        var_dump($response->body->resultObject->subCode);
        var_dump($response->body->resultObject->materialInfo);
        var_dump($response->body->resultObject->identityInfo);
        var_dump($response->body->resultObject->deviceToken);
    }

    /**
     * describeFaceVerifyAutoRoute
     * @param DescribeFaceVerifyRequest $request
     * @return DescribeFaceVerifyResponse|null
     */
    public static function describeFaceVerifyAutoRoute(DescribeFaceVerifyRequest $request): ?DescribeFaceVerifyResponse
    {
        $endpoints = [
            "cloudauth.cn-shanghai.aliyuncs.com",
            "cloudauth.cn-beijing.aliyuncs.com"
        ];
        foreach($endpoints as $endpoint){
            try {
                $response = self::describeFaceVerify($endpoint, $request);
                if (Utils::equalNumber(500, $response->statusCode)) {
                    continue;
                }
                if(Utils::equalString("500", $response->body->code)){
                    continue;
                }
                return $response;
            }
            catch (Exception $err) {
                var_dump($err -> getCode());
                var_dump($err -> getMessage());
            }
        }
        return null;
    }

    /**
     * describeFaceVerify
     * @param string $endpoint
     * @param DescribeFaceVerifyRequest $request
     * @return DescribeFaceVerifyResponse
     */
    public static function describeFaceVerify(string $endpoint, DescribeFaceVerifyRequest $request): DescribeFaceVerifyResponse
    {
        $client = self::createClient($endpoint);
        // 創建RuntimeObject實例并設置運行參數。
        $runtime = new RuntimeOptions([]);
        $runtime->readTimeout = 10000;
        $runtime->connectTimeout = 10000;
        return $client->describeFaceVerifyWithOptions($request, $runtime);
    }
}
$path = __DIR__ . \DIRECTORY_SEPARATOR . \DIRECTORY_SEPARATOR . 'vendor' . \DIRECTORY_SEPARATOR . 'autoload.php';
if (file_exists($path)) {
    require_once $path;
}
DescribeFaceVerify::main();

Python

InitFaceVerify接口調用示例

from alibabacloud_cloudauth20190307.client import Client as CloudauthClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_cloudauth20190307 import models as cloudauth_models
from alibabacloud_tea_util.client import Client as UtilClient
from alibabacloud_tea_util import models as util_models
from alibabacloud_credentials.client import Client as CredClient


class InitFaceVerify:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
            endpoint: str,
    ) -> CloudauthClient:
        # 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
		    # 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
		    # 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
        cred=CredClient()
        config = open_api_models.Config(
            credential=cred,
            # 設置HTTP代理。
            # http_proxy='http://xx.xx.xx.xx:xxxx',
            # 設置HTTPS代理。
            # https_proxy='https://username:password@xxx.xxx.xxx.xxx:9999',
            endpoint=endpoint
        )
        return CloudauthClient(config)

    @staticmethod
    def main() -> None:
        request = cloudauth_models.InitFaceVerifyRequest(
            # 請輸入場景ID。
            scene_id=0,
            outer_order_no='商戶請求的唯一標識',
            # 要接入的認證方案。
            product_code='ID_PRO',
            model='LIVENESS',
            # 固定值IDENTITY_CARD。
            cert_type='IDENTITY_CARD',
            cert_name='xxx',
            cert_no='xxx',
            # MetaInfo環境參數,需要通過客戶端SDK獲取。
            meta_info='{"zimVer":"3.0.0","appVersion": "1","bioMetaInfo": "4.1.0:11501568,0","appName": "com.aliyun.antcloudauth","deviceType": "ios","osVersion": "iOS 10.3.2","apdidToken": "","deviceModel": "iPhone9,1"}',
            # mobile='130xxxxxxxx',
            # ip='114.xxx.xxx.xxx',
            # user_id='12345xxxx',
            # callback_url='https://www.aliyundoc.com',
            # callback_token='xxxxxxx',
            # 如需開啟個人信息加密傳輸。
            # encrypt_type='SM2',
            # cert_name='BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==',
            # cert_no='BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg=='
        )
        response = InitFaceVerify.init_face_verify_auto_route(request)
        # 不支持服務自動路由。
        # response = InitFaceVerify.init_face_verify('cloudauth.cn-shanghai.aliyuncs.com', request)
        print(response.body.request_id)
        print(response.body.code)
        print(response.body.message)
        print(response.body.result_object.certify_id)

    @staticmethod
    def init_face_verify_auto_route(
            request: cloudauth_models.InitFaceVerifyRequest,
    ) -> cloudauth_models.InitFaceVerifyResponse:
        endpoints = [
            'cloudauth.cn-shanghai.aliyuncs.com',
            'cloudauth.cn-beijing.aliyuncs.com'
        ]
        for endpoint in endpoints:
            try:
                response = InitFaceVerify.init_face_verify(endpoint, request)
                if UtilClient.equal_number(500, response.status_code):
                    continue
                if response is not None and response.body is not None:
                    if UtilClient.equal_string("500", response.body.code):
                        continue
                return response
            except Exception as err:
                print(err)
                # 網絡異常,切換到下個區域調用。
                continue
        return None

    @staticmethod
    def init_face_verify(
            endpoint: str,
            request: cloudauth_models.InitFaceVerifyRequest,
    ) -> cloudauth_models.InitFaceVerifyResponse:
        client = InitFaceVerify.create_client(endpoint)
        # 創建RuntimeObject實例并設置運行參數。
        runtime = util_models.RuntimeOptions()
        runtime.read_timeout = 10000
        runtime.connect_timeout = 10000
        return client.init_face_verify_with_options(request, runtime)


if __name__ == '__main__':
    InitFaceVerify.main()
            

DescribeFaceVerify接口調用示例

from alibabacloud_cloudauth20190307.client import Client as CloudauthClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_cloudauth20190307 import models as cloudauth_models
from alibabacloud_tea_util.client import Client as UtilClient
from alibabacloud_tea_util import models as util_models
from alibabacloud_credentials.client import Client as CredClient


class DescribeFaceVerify:
    def __init__(self):
        pass

    @staticmethod
    def create_client(
            endpoint: str,
    ) -> CloudauthClient:
        # 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
		    # 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
		    # 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
        cred=CredClient()
        config = open_api_models.Config(
            credential=cred,
            # 設置HTTP代理。
            # http_proxy='http://xx.xx.xx.xx:xxxx',
            # 設置HTTPS代理。
            # https_proxy='https://username:password@xxx.xxx.xxx.xxx:9999',
            endpoint=endpoint
        )
        return CloudauthClient(config)

    @staticmethod
    def main() -> None:
        request = cloudauth_models.DescribeFaceVerifyRequest(
            # 請輸入場景ID。
            scene_id=0,
            certify_id='xxx'
        )
        response = DescribeFaceVerify.describe_face_verify_auto_route(request)
        # 不支持服務自動路由。
        # response = DescribeFaceVerify.describe_face_verify('cloudauth.cn-shanghai.aliyuncs.com', request)
        print(response.body.request_id)
        print(response.body.code)
        print(response.body.message)
        print(response.body.result_object.passed)
        print(response.body.result_object.sub_code)
        print(response.body.result_object.material_info)

    @staticmethod
    def describe_face_verify_auto_route(
            request: cloudauth_models.DescribeFaceVerifyRequest,
    ) -> cloudauth_models.DescribeFaceVerifyResponse:
        endpoints = [
            'cloudauth.cn-shanghai.aliyuncs.com',
            'cloudauth.cn-beijing.aliyuncs.com'
        ]
        for endpoint in endpoints:
            try:
                response = DescribeFaceVerify.describe_face_verify(endpoint, request)
                if UtilClient.equal_number(500, response.status_code):
                    continue
                if response is not None and response.body is not None:
                    if UtilClient.equal_string("500", response.body.code):
                        continue
                return response
            except Exception as err:
                print(err)
                continue
        return None

    @staticmethod
    def describe_face_verify(
            endpoint: str,
            request: cloudauth_models.DescribeFaceVerifyRequest,
    ) -> cloudauth_models.DescribeFaceVerifyResponse:
        client = DescribeFaceVerify.create_client(endpoint)
        # 創建RuntimeObject實例并設置運行參數。
        runtime = util_models.RuntimeOptions()
        runtime.read_timeout = 10000
        runtime.connect_timeout = 10000
        return client.describe_face_verify_with_options(request, runtime)


if __name__ == '__main__':
    DescribeFaceVerify.main()
            

GO

InitFaceVerify接口調用示例

package main


import (
	"fmt"
	cloudauth "github.com/alibabacloud-go/cloudauth-20190307/v3/client"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
  "github.com/aliyun/credentials-go/credentials"
)


func CreateClient (endpoint *string) (_result *cloudauth.Client, _err error) {
	//阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
  //強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
  //本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
  // 初始化Credential。
	credential, _err := credentials.NewCredential(nil)
	if _err != nil {
		panic(_err)
	}
	// 初始化Client。
	config := &openapi.Config{
	// 使用Credential配置憑證。
	Credential: credential,
	Endpoint:   endpoint,
	// 設置HTTP代理。
	// HttpProxy: tea.String("http://xx.xx.xx.xx:xxxx"),
	// 設置HTTPS代理。
	// HttpsProxy: tea.String("https://username:password@xxx.xxx.xxx.xxx:9999"),
	}
	//_result = &cloudauth.Client{}
	_result, _err = cloudauth.NewClient(config)
	return _result, _err
}

func _main () (_err error) {
	request := &cloudauth.InitFaceVerifyRequest{
		// 固定值。
		ProductCode: tea.String("ID_PRO"),
		// 請輸入場景ID。
		SceneId: tea.Int64(xxx),
		OuterOrderNo: tea.String("商戶請求的唯一標識"),
		Model: tea.String("LIVENESS"),
		// 固定值IDENTITY_CARD。
		CertType: tea.String("IDENTITY_CARD"),
		CertName: tea.String("xxx"),
		CertNo: tea.String("xxx"),
		MetaInfo: tea.String("{\"zimVer\":\"3.0.0\",\"appVersion\": \"1\",\"bioMetaInfo\": \"4.1.0:11501568,0\",\"appName\": \"com.aliyun.antcloudauth\",\"deviceType\": \"ios\",\"osVersion\": \"iOS 10.3.2\",\"apdidToken\": \"\",\"deviceModel\": \"iPhone9,1\"}"),
		// Ip: tea.String("用戶IP地址"),
		// UserId: tea.String("用戶ID"),
		// Mobile: tea.String("130xxxxxxxx"),
		// CallbackUrl: tea.String("https://www.aliyundoc.com"),
		// CallbackToken: tea.String("xxxxxxx"),
		// 如需開啟個人信息加密傳輸。
		// EncryptType: tea.String("SM2"),
		// CertName: tea.String("BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w=="),
		// CertNo: tea.String("BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg==")
	}
	response, _err := InitFaceVerifyAutoRoute(request)
	// 不支持服務自動路由。
	// response, _err := InitFaceVerify(tea.String("cloudauth.cn-shanghai.aliyuncs.com"), request)
	if _err != nil {
		return _err
	}

	fmt.Println(*response.Body.RequestId)
	fmt.Println(*response.Body.Code)
	fmt.Println(*response.Body.Message)
	fmt.Println(*response.Body.RequestId)
	fmt.Println(*response.Body.ResultObject.CertifyId)
	return _err
}

func InitFaceVerifyAutoRoute (request *cloudauth.InitFaceVerifyRequest) (_result *cloudauth.InitFaceVerifyResponse, _err error) {
	endpoints := []*string{tea.String("cloudauth.cn-shanghai.aliyuncs.com"), tea.String("cloudauth.cn-beijing.aliyuncs.com")}
	var lastResponse *cloudauth.InitFaceVerifyResponse
	for _, endpoint := range endpoints {
		response, _err := InitFaceVerify(endpoint, request)
        lastResponse = response
		if _err != nil {
			var err = &tea.SDKError{}
			if _t, ok := _err.(*tea.SDKError); ok {
				err = _t
				// 系統異常,切換到下個地域調用。
				if *err.StatusCode == 500 {
					continue
				}
			}
			return _result, _err
		}

		if *response.StatusCode == 500 {
			continue
		}

		if *response.Body.Code == "500"{
			continue
		}

		_result = response
		return _result, _err
	}
	_result = lastResponse
	return _result, _err
}

func InitFaceVerify (endpoint *string, request *cloudauth.InitFaceVerifyRequest) (_result *cloudauth.InitFaceVerifyResponse, _err error) {
	client, _err := CreateClient(endpoint)
	if _err != nil {
		return _result, _err
	}

	// 創建RuntimeObject實例并設置運行參數。
	runtime := &util.RuntimeOptions{}
	runtime.ReadTimeout = tea.Int(10000)
	runtime.ConnectTimeout = tea.Int(10000)

	_result = &cloudauth.InitFaceVerifyResponse{}
	_body, _err := client.InitFaceVerifyWithOptions(request, runtime)
	if _err != nil {
		return _result, _err
	}
	_result = _body
	return _result, _err
}

func main() {
	err := _main()
	if err != nil {
		panic(err)
	}
}

DescribeFaceVerify接口調用示例

package main

import (
	"fmt"
	cloudauth "github.com/alibabacloud-go/cloudauth-20190307/v3/client"
	openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
	util "github.com/alibabacloud-go/tea-utils/v2/service"
	"github.com/alibabacloud-go/tea/tea"
  "github.com/aliyun/credentials-go/credentials"
)

func CreateClient(endpoint *string) (_result *cloudauth.Client, _err error) {
	//阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
  //強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
  //本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
  // 初始化Credential。
	credential, _err := credentials.NewCredential(nil)
	if _err != nil {
		panic(_err)
	}
	// 初始化Client。
	config := &openapi.Config{
	// 使用Credential配置憑證。
	Credential: credential,
	Endpoint:   endpoint,
	// 設置HTTP代理。
	// HttpProxy: tea.String("http://xx.xx.xx.xx:xxxx"),
	// 設置HTTPS代理。
	// HttpsProxy: tea.String("https://username:password@xxx.xxx.xxx.xxx:9999"),
	}
	//_result = &cloudauth.Client{}
	_result, _err = cloudauth.NewClient(config)
	return _result, _err
}

func _main() (_err error) {
	request := &cloudauth.DescribeFaceVerifyRequest{
		// 請輸入場景ID。
		SceneId:   tea.Int64(xxx),
		CertifyId: tea.String("91707dc296d469ad38e4c5efa6a0xxxx"),
	}
	response, _err := DescribeFaceVerifyAutoRoute(request)

	// 不支持服務自動路由。
	// response, _err := DescribeFaceVerify(tea.String("cloudauth.cn-shanghai.aliyuncs.com"), request)

	if _err != nil {
		return _err
	}

	if response != nil {
		fmt.Println(*response.Body.RequestId)
		fmt.Println(*response.Body.Code)
		fmt.Println(*response.Body.Message)
		fmt.Println(*response.Body.RequestId)
		fmt.Println(*response.Body.ResultObject.Passed)
		fmt.Println(*response.Body.ResultObject.SubCode)
		fmt.Println(*response.Body.ResultObject.MaterialInfo)
		fmt.Println(*response.Body.ResultObject.IdentityInfo)
		fmt.Println(*response.Body.ResultObject.DeviceToken)
	}

	return _err
}

func DescribeFaceVerifyAutoRoute(request *cloudauth.DescribeFaceVerifyRequest) (_result *cloudauth.DescribeFaceVerifyResponse, _err error) {
	endpoints := []*string{tea.String("cloudauth.cn-shanghai.aliyuncs.com"), tea.String("cloudauth.cn-beijing.aliyuncs.com")}
	var lastResponse *cloudauth.DescribeFaceVerifyResponse
	for _, endpoint := range endpoints {
		response, _err := DescribeFaceVerify(endpoint, request)
		lastResponse = response
		if _err != nil {
			var err = &tea.SDKError{}
			if _t, ok := _err.(*tea.SDKError); ok {
				err = _t
				// 系統異常,切換到下個地域調用。
				if *err.StatusCode == 500 {
					continue
				}
			}
			return _result, _err
		}

		if *response.StatusCode == 500 {
			continue
		}

		if *response.Body.Code == "500"{
			continue
		}

		_result = response
		return _result, _err

	}
	_result = lastResponse
	return _result, _err
}

func DescribeFaceVerify(endpoint *string, request *cloudauth.DescribeFaceVerifyRequest) (_result *cloudauth.DescribeFaceVerifyResponse, _err error) {
	client, _err := CreateClient(endpoint)
	if _err != nil {
		return _result, _err
	}

	// 創建RuntimeObject實例并設置運行參數。
	runtime := &util.RuntimeOptions{}
	runtime.ReadTimeout = tea.Int(10000)
	runtime.ConnectTimeout = tea.Int(10000)

	_body, _err := client.DescribeFaceVerifyWithOptions(request, runtime)
	if _err != nil {
		return _result, _err
	}
	_result = _body
	return _result, _err
}

func main() {
	err := _main()
	if err != nil {
		panic(err)
	}
}

.NET

InitFaceVerify接口調用示例

using System;

using System.Collections.Generic;
using Tea;


namespace InitFaceVerify
{
    public class Program
    {

        public static AlibabaCloud.SDK.Cloudauth20190307.Client CreateClient(string endpoint)
        {
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
               Credential=new Aliyun.Credentials.Client(null)
            };
  					config.Endpoint = endpoint;
            return new AlibabaCloud.SDK.Cloudauth20190307.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyRequest request = new AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyRequest
            {
                // 固定值。
                ProductCode = "ID_PRO",
                // 請輸入場景ID。
                SceneId = xxx,
                // 設置商戶請求的唯一標識。
                OuterOrderNo = "xxxxx",
                // 模式。
                Model = "LIVENESS",
                // 固定值IDENTITY_CARD。
                CertType = "IDENTITY_CARD",
                CertName = "xxx",
                CertNo = "xxx",
                MetaInfo = "{\"zimVer\":\"3.0.0\",\"appVersion\": \"1\",\"bioMetaInfo\": \"4.1.0:11501568,0\",\"appName\": \"com.aliyun.antcloudauth\",\"deviceType\": \"ios\",\"osVersion\": \"iOS 10.3.2\",\"apdidToken\": \"\",\"deviceModel\": \"iPhone9,1\"}",
                //Mobile = "130xxxxxxxx",
                //Ip = "114.xxx.xxx.xxx",
                //UserId = "用戶ID",
                //CallbackUrl = "https://www.aliyundoc.com",
                //CallbackToken = "xxxxxxx",
                // 如需開啟個人信息加密傳輸。
                // EncryptType = "SM2",
                // CertName = "BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==",
                // CertNo = "BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg=="
            };
            AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse response = InitFaceVerifyAutoRoute(request);
            // 不支持服務自動路由。
            // AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse response = InitFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
            Console.WriteLine(response.Body.RequestId);
            Console.WriteLine(response.Body.Code);
            Console.WriteLine(response.Body.Message);
            Console.WriteLine(response.Body.ResultObject.CertifyId);
        }


        public static AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse InitFaceVerifyAutoRoute(AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyRequest request)
        {
            List<string> endpoints = new List<string>
            {
                "cloudauth.cn-shanghai.aliyuncs.com",
                "cloudauth.cn-beijing.aliyuncs.com"
            };
            AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse lastResponse = null;

            foreach (var endpoint in endpoints)
            {
                try
                {
                    AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse response = InitFaceVerify(endpoint, request);
                    lastResponse = response;
                    if (response is not null)
                    {
                        if (AlibabaCloud.TeaUtil.Common.EqualNumber(500, (int)(response.StatusCode)))
                        {
                            continue;
                        }

                        if (response.Body is not null)
                        {
                            if (AlibabaCloud.TeaUtil.Common.EqualString("500", response.Body.Code))
                            {
                                continue;
                            }
                        }
                    }
                    return response;
                }
                catch (TeaException err)
                {
                    Console.WriteLine(err);
                    // 網絡異常,切換到下個區域調用。
                    if (AlibabaCloud.TeaUtil.Common.EqualString("ServiceUnavailable", err.Code))
                    {
                        continue;
                    }
                }
                catch (Exception _err)
                {
                    Console.WriteLine(_err);
                    continue;
                }
            }
            return lastResponse;
        }

        public static AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyResponse InitFaceVerify(string endpoint, AlibabaCloud.SDK.Cloudauth20190307.Models.InitFaceVerifyRequest request)
        {
            AlibabaCloud.SDK.Cloudauth20190307.Client client = CreateClient(endpoint);
            // 創建RuntimeObject實例并設置運行參數。
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            runtime.ReadTimeout = 10000;
            runtime.ConnectTimeout = 10000;
            return client.InitFaceVerifyWithOptions(request, runtime);
        }
    }
}

DescribeFaceVerify接口調用示例

using System;

using System.Collections.Generic;
using Tea;


namespace DescribeFaceVerify
{
    public class Program
    {

        public static AlibabaCloud.SDK.Cloudauth20190307.Client CreateClient(string endpoint)
        {
             AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
               Credential=new Aliyun.Credentials.Client(null)
            };
  					config.Endpoint = endpoint;
            return new AlibabaCloud.SDK.Cloudauth20190307.Client(config);
        }

        public static void Main(string[] args)
        {
            AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyRequest request = new AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyRequest
            {
                // 請輸入場景ID。
                SceneId = xxxx,
                CertifyId = "91707dxxxx4c5efa6a0xxxx",
            };
            AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse response = DescribeFaceVerifyAutoRoute(request);
            // 不支持服務自動路由。
            // AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse response = DescribeFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
            Console.WriteLine(response.Body.RequestId);
            Console.WriteLine(response.Body.Code);
            Console.WriteLine(response.Body.Message);
            Console.WriteLine(response.Body.ResultObject.Passed);
            Console.WriteLine(response.Body.ResultObject.SubCode);
            Console.WriteLine(response.Body.ResultObject.MaterialInfo);
            Console.WriteLine(response.Body.ResultObject.IdentityInfo);
            Console.WriteLine(response.Body.ResultObject.DeviceToken);
        }


        public static AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse DescribeFaceVerifyAutoRoute(AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyRequest request)
        {
            List<string> endpoints = new List<string>
            {
                "cloudauth.cn-shanghai.aliyuncs.com",
                "cloudauth.cn-beijing.aliyuncs.com"
            };
            AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse lastResponse = null;

            foreach (var endpoint in endpoints)
            {
                try
                {
                    AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse response = DescribeFaceVerify(endpoint, request);
                    lastResponse = response;
                    if (response is not null)
                    {
                        if (AlibabaCloud.TeaUtil.Common.EqualNumber(500, (int)(response.StatusCode)))
                        {
                            continue;
                        }

                        if (response.Body is not null)
                        {
                            if (AlibabaCloud.TeaUtil.Common.EqualString("500", response.Body.Code))
                            {
                                continue;
                            }
                        }
                    }
                    return response;
                }
                catch (TeaException err)
                {
                    Console.WriteLine(err);
                    // 網絡異常,切換到下個區域調用。
                    if (AlibabaCloud.TeaUtil.Common.EqualString("ServiceUnavailable", err.Code))
                    {
                        continue;
                    }
                }
                catch (Exception _err)
                {
                    Console.WriteLine(_err);
                    continue;
                }
            }
            return lastResponse;
        }

        public static AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyResponse DescribeFaceVerify(string endpoint, AlibabaCloud.SDK.Cloudauth20190307.Models.DescribeFaceVerifyRequest request)
        {
            AlibabaCloud.SDK.Cloudauth20190307.Client client = CreateClient(endpoint);
            // 創建RuntimeObject實例并設置運行參數。
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            runtime.ReadTimeout = 10000;
            runtime.ConnectTimeout = 10000;
            return client.DescribeFaceVerifyWithOptions(request, runtime);
        }
    }
}

Node.js

InitFaceVerify接口調用示例

const Config = require("@alicloud/openapi-client");
const CloudAuth = require("@alicloud/cloudauth20190307");
const CloudAuthClient = CloudAuth.default;
const { RuntimeOptions } = require("@alicloud/tea-util");
const { default: Credential } = require('@alicloud/credentials');

function createClient(endpoint) {
    // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
 	  // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
	  // 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
    const cred = new Credential();
    const config = new Config.Config({
    credential: cred,
    // 設置Endpoint。
    endpoint: endpoint,
    // 設置HTTP代理。
    // httpProxy: "http://xxx.xxx.xxx.xxx:9999",
    // 設置HTTPS代理。
    // httpsProxy: "https://username:password@xxx.xxx.xxx.xxx:9999",
  });
  return new CloudAuthClient(config);
}

async function initFaceVerify(endpoint, request) {
    const client = createClient(endpoint);
    // 創建RuntimeObject實例并設置運行參數。
    const runtime = new RuntimeOptions([]);
    runtime.readTimeout=10000;
    runtime.connectTimeout=10000;
    return await client.initFaceVerifyWithOptions(request, runtime);
}

async function initFaceVerifyAutoRoute(request) {
    const endpoints = [
        "cloudauth.cn-shanghai.aliyuncs.com",
        "cloudauth.cn-beijing.aliyuncs.com"
    ];

    for (const endpoint of endpoints) {
        try {
            const response = await initFaceVerify(endpoint, request);
            if (response.statusCode === 500) {
                continue;
            }
            if(response.body !== null){
                if(response.body.code === "500"){
                    continue;
                }
            }
            return response;
        } catch (err) {
            console.log(err);
            continue;
        }
    }
    return null;
}

async function main(){
    // 通過以下代碼創建API請求并設置參數。
    const request = new CloudAuth.InitFaceVerifyRequest({
        // 請輸入場景ID。
        sceneId: xxx,
        // 設置商戶請求的唯一標識。
        outerOrderNo: "xxx",
        // 要接入的認證方案。
        productCode: "ID_PRO",
        // 模式。
        model: "LIVENESS",
        // 固定值。
        certType: "IDENTITY_CARD",
        certName: "張三",
        certNo: "xxx",
        metaInfo: "{\"zimVer\":\"3.0.0\",\"appVersion\": \"1\",\"bioMetaInfo\": \"4.1.0:11501568,0\",\n" +
            "        \"appName\": \"com.aliyun.antcloudauth\",\"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",
        // 如需開啟個人信息加密傳輸。
        // encryptType: "SM2",
        // certName: "BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==",
        // certNo: "BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg=="
    });

    // 推薦,支持服務路由。
    const response = await initFaceVerifyAutoRoute(request);
    // 不支持服務自動路由。
    // const response = await initFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
    if (response){
        console.log(response);
        console.log(response.body.requestId);
        console.log(response.body.code);
        console.log(response.body.message);
        console.log(response.body.resultObject.certifyId);
    }
}
main().then(function (response) {});

DescribeFaceVerify接口調用示例

const Config = require("@alicloud/openapi-client");
const CloudAuth = require("@alicloud/cloudauth20190307");
const CloudAuthClient = CloudAuth.default;
const {RuntimeOptions} = require("@alicloud/tea-util");
const Credential = require("@alicloud/credentials");

function createClient(endpoint) {
    // 阿里云賬號AccessKey擁有所有API的訪問權限,建議您使用RAM用戶進行API訪問或日常運維。
 	  // 強烈建議不要把AccessKey ID和AccessKey Secret保存到工程代碼里,否則可能導致AccessKey泄露,威脅您賬號下所有資源的安全。
	  // 本示例通過阿里云Credentials工具從環境變量中讀取AccessKey,來實現API訪問的身份驗證。
    const cred = new Credential();
    const config = new Config.Config({
    credential: cred,
    // 設置Endpoint。
    endpoint: endpoint,
    // 設置HTTP代理。
    // httpProxy: "http://xxx.xxx.xxx.xxx:9999",
    // 設置HTTPS代理。
    // httpsProxy: "https://username:password@xxx.xxx.xxx.xxx:9999",
  });
  return new CloudAuthClient(config);
}

async function describeFaceVerify(endpoint, request) {
    const client = createClient(endpoint);
    // 創建RuntimeObject實例并設置運行參數。
    const runtime = new RuntimeOptions([]);
    runtime.readTimeout=10000;
    runtime.connectTimeout=10000;
    return await client.describeFaceVerifyWithOptions(request, runtime);
}

async function describeFaceVerifyAutoRoute(request) {
    const endpoints = [
        "cloudauth.cn-shanghai.aliyuncs.com",
        "cloudauth.cn-beijing.aliyuncs.com"
    ];

    for (const endpoint of endpoints) {
        try {
            const response = await describeFaceVerify(endpoint, request);
            if (response.statusCode === 500) {
                continue;
            }
            if(response.body !== null){
                if(response.body.code === "500"){
                    continue;
                }
            }
            return response;
        } catch (err) {
            console.log(err);
            continue;
        }
    }
    return null;
}

async function main(){
    // 通過以下代碼創建API請求并設置參數。
    const request = new CloudAuth.DescribeFaceVerifyRequest({
    sceneId: xxx,
    certifyId: "xxx"
    });
    // 推薦,支持服務路由。
    const response = await describeFaceVerifyAutoRoute(request);
    // 不支持服務自動路由。
    //  const response = await describeFaceVerify("cloudauth.cn-shanghai.aliyuncs.com", request);
    if (response){
       console.log(response.body.requestId);
       console.log(response.body.code);
       console.log(response.body.message);
       console.log(response.body.resultObject.passed);
       console.log(response.body.resultObject.identityInfo);
       console.log(response.body.resultObject.materialInfo);
       console.log(response.body.resultObject.deviceToken);
       console.log(response.body.resultObject.subCode);
	   }
	   }

main().then(function (response) {});