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

PHP SDK調用示例

本文介紹了金融級實人認證純服務端API的PHP SDK調用示例。

SDK使用說明

如果需要其他語言的SDK示例代碼,您可以通過OpenAPI 開發者門戶在線調試工具調試API接口,該工具會自動生成相應API的SDK調用示例代碼。您可以單擊以下接口鏈接進行調試:

調試ContrastFaceVerify接口

前提條件

  • 僅支持PHP 5.6及以上版本。

  • 已添加認證場景,并獲取對應的場景ID。具體操作,請參見添加認證場景

安裝SDK

關于PHP SDK源代碼,請參見PHP SDK包

  • 通過Composer來管理項目依賴(推薦)

    composer require alibabacloud/cloudauth-20190307 2.0.4
  • 使用composer.json文件

    {
       "require": {
           "alibabacloud/cloudauth-20190307": "2.0.4"
        }
    }

如果因網絡問題導致無法按照上述操作安裝SDK,您可以使用阿里云Composer全量鏡像

照片實人認證調用示例

關于參數的具體描述,請參見照片實人認證

<?php


namespace AlibabaCloud\SDK\Sample\Verify\Id;

use AlibabaCloud\Credentials\Credential; 
use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyRequest;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyResponse;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use Exception;

class ContrastFaceVerifyWithPicture
{
    /**
     * 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訪問的身份驗證。如何配置環境變量,請參見 http://bestwisewords.com/document_detail/311677.html。 
        $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);
    }

    /**
     * @return void
     */
    public static function main(){
        $request = new ContrastFaceVerifyRequest([
            // 請輸入場景ID。
            "sceneId" => 0,
            "outerOrderNo" => "<商戶請求的唯一標識>",
            // 要接入的認證方案。
            "productCode" => "<ID_MIN>",
            // 要進行活體檢測的類型。
            "model" => "<NO_LIVENESS>",
            "certType" => "<IDENTITY_CARD>",
            "certName" => "<xxx>",
            "certNo" => "<xxx>",
            // "deviceToken" => "<McozS1ZWRcRZStlERcZZo_QOytx5jcgZoZJEoRLOxxxxxxx>",
            // "mobile" => "<xxx>",
            // "ip" => "<114.xxx.xxx.xxx>",
            // "userId" => "<12345xxxx>",
            // 請在以下四種方式中選擇其一。
            // 1.照片Base64編碼。
            // 2.照片OSS Bucket名和文件名。
            // 3.照片OSS的URL地址。
            // 4.已經實人認證通過的CertifyId。

            // 方式一:照片Base64。
            // "faceContrastPicture" => "<人臉照片Base64編碼>",
            // 方式二:照片OSS bucket名和文件名。
            // "ossBucketName" => "<cn-shanghai-aliyun-cloudauth-xxxxx>",
            // "ossObjectName" => "<verify/xxxxx/xxxxxx.jpeg>",
            // 方式三:照片OSS的URL地址,公網可訪問。
            "faceContrastPictureUrl" => "<https://cn-shanghai-aliyun-cloudauth-xxxxxx.oss-cn-shanghai.aliyuncs.com/verify/xxxxx/xxxxx.jpeg>",
            // 方式四:已經實人認證通過的CertifyId。
            // "certifyId" => "<0bfa7c493f850e5178b9f8613634c9xx>",

            // 如需開啟個人信息加密傳輸。
            // "encryptType" => "<SM2>",
            // "certName" => "<BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==>",
            // "certNo" => "<BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg==>"
        ]);
        // 推薦,支持服務路由。
        $response = self::contrastFaceVerifyAutoRoute($request);
        // 不支持服務自動路由。
        // $response = self::contrastFaceVerify("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->materialInfo);
        var_dump($response->body->resultObject->subCode);
        var_dump($response->body->resultObject->identityInfo);
        var_dump($response->body->resultObject->passed);
    }

    /**
     * contrastFaceVerifyAutoRoute
     * @param ContrastFaceVerifyRequest $request
     * @return ContrastFaceVerifyResponse|null
     */
    public static function contrastFaceVerifyAutoRoute(ContrastFaceVerifyRequest $request): ?ContrastFaceVerifyResponse
    {
        $endpoints = [
            "cloudauth.cn-shanghai.aliyuncs.com",
            "cloudauth.cn-beijing.aliyuncs.com"
        ];
        foreach($endpoints as $endpoint){
            try {
                $response = self::contrastFaceVerify($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;
    }

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

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

視頻實人認證調用示例

支持OSS對象存儲方式和本地文件兩種方式。關于參數的具體描述,請參見視頻實人認證

使用本地文件的方式(推薦)

<?php


namespace AlibabaCloud\SDK\Sample\Verify\Id;

use AlibabaCloud\Credentials\Credential; 
use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyAdvanceRequest;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyResponse;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use GuzzleHttp\Psr7\Stream;

class ContrastFaceVerifyWithVideoFile
{
    /**
     * 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訪問的身份驗證。如何配置環境變量,請參見 http://bestwisewords.com/document_detail/311677.html。 
        $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);
    }

    /**
     * @return void
     */
    public static function main(){
        $file = new Stream(fopen('本地文件路徑', 'r'));
        $request = new ContrastFaceVerifyAdvanceRequest([
            // 請輸入場景ID。
            "sceneId" => 0,
            "outerOrderNo" => "<商戶請求的唯一標識>",
            // 要接入的認證方案。
            "productCode" => "<ID_MIN_VIDEO>",
            // 要進行活體檢測的類型。
            "model" => "<FRONT_CAMERA_LIVENESS>",
            "certType" => "<IDENTITY_CARD>",
            "certName" => "<xxx>",
            "certNo" => "<xxx>",
            // "deviceToken" => "<McozS1ZWRcRZStlERcZZo_QOytx5jcgZoZJEoRLOxxxxxxx>",
            // "mobile" => "<xxx>",
            // "ip" => "<114.xxx.xxx.xxx>",
            // "userId" => "<12345xxxx>",
            "faceContrastFileObject" => $file,
            // 如需開啟個人信息加密傳輸。
            // "encryptType" => "<SM2>",
            // "certName" => "<BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==>",
            // "certNo" => "<BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg==>"
        ]);
        try {
            // 推薦,支持服務路由。
             $response = self::contrastFaceVerifyAutoRoute($request);
            // 不支持服務自動路由。
            // $response = self::contrastFaceVerify("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->materialInfo);
            var_dump($response->body->resultObject->subCode);
            var_dump($response->body->resultObject->identityInfo);
            var_dump($response->body->resultObject->passed);
        } finally {
            fclose($file);
        }
    }

    /**
     * contrastFaceVerifyAutoRoute
     * @param ContrastFaceVerifyAdvanceRequest $request
     * @return ContrastFaceVerifyResponse|null
     */
    public static function contrastFaceVerifyAutoRoute(ContrastFaceVerifyAdvanceRequest $request): ?ContrastFaceVerifyResponse
    {
        $endpoints = [
            "cloudauth.cn-shanghai.aliyuncs.com",
            "cloudauth.cn-beijing.aliyuncs.com"
        ];
        foreach($endpoints as $endpoint){
            try {
                $response = self::contrastFaceVerify($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;
    }

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

使用OSS對象存儲的方式

<?php


namespace AlibabaCloud\SDK\Sample\Verify\Id;

use AlibabaCloud\Credentials\Credential; 
use AlibabaCloud\SDK\Cloudauth\V20190307\Cloudauth;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyRequest;
use AlibabaCloud\SDK\Cloudauth\V20190307\Models\ContrastFaceVerifyResponse;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;

class ContrastFaceVerifyWithVideoOSS
{
    /**
     * 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訪問的身份驗證。如何配置環境變量,請參見 http://bestwisewords.com/document_detail/311677.html。 
        $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 ContrastFaceVerifyRequest([
            // 請輸入場景ID。
            "sceneId" => 0,
            "outerOrderNo" => "<商戶請求的唯一標識>",
            // 要接入的認證方案。
            "productCode" => "<ID_MIN_VIDEO>",
            // 要進行活體檢測的類型。
            "model" => "<FRONT_CAMERA_LIVENESS>",
            "certType" => "<IDENTITY_CARD>",
            "certName" => "<xxx>",
            "certNo" => "<xxx>",
            // "deviceToken" => "<McozS1ZWRcRZStlERcZZo_QOytx5jcgZoZJEoRLOxxxxxxx>",
            // "mobile" => "<xxx>",
            // "ip" => "<114.xxx.xxx.xxx>",
            // "userId" => "<12345xxxx>",
            "ossBucketName" => "<cn-shanghai-aliyun-cloudauth-xxxxx>",
            "ossObjectName" => "<verify/xxxxx/xxxxxx.mp4>",
            // 如需開啟個人信息加密傳輸。
            // "encryptType" => "<SM2>",
            // "certName" => "<BCRD/7ZkNy7Q*****M1BMBezZe8GaYHrLwyJv558w==>",
            // "certNo" => "<BMjsstxK3S4b1YH*****Pet8ECObfxmLN92SLsNg==>"
        ]);
        // 推薦,支持服務路由。
        $response = self::contrastFaceVerifyAutoRoute($request);
        // 不支持服務自動路由。
        // $response = self::contrastFaceVerify("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->materialInfo);
        var_dump($response->body->resultObject->subCode);
        var_dump($response->body->resultObject->identityInfo);
        var_dump($response->body->resultObject->passed);
    }

    /**
     * contrastFaceVerifyAutoRoute
     * @param ContrastFaceVerifyRequest $request
     * @return ContrastFaceVerifyResponse|null
     */
    public static function contrastFaceVerifyAutoRoute(ContrastFaceVerifyRequest $request): ?ContrastFaceVerifyResponse
    {
        $endpoints = [
            "cloudauth.cn-shanghai.aliyuncs.com",
            "cloudauth.cn-beijing.aliyuncs.com"
        ];
        foreach($endpoints as $endpoint){
            try {
                $response = self::contrastFaceVerify($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;
    }

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