すべてのプロダクト
Search
ドキュメントセンター

ID Verification:SDK for Java の呼び出し例

最終更新日:Apr 01, 2025

このトピックでは、ID Verification - KYC SDK for Java のサーバーサイド専用 API オペレーションの呼び出し例を紹介します。KYC は Know Your Customer の略です。

前提条件

  • Java Development Kit(JDK)1.8 以降がインストールされている。

  • Alibaba Cloud が提供する認証情報を使用して、API アクセスのための認証が構成されている。

    説明

    認証情報を使用して API アクセスのための認証を構成する方法の詳細については、[アクセスクレデンシャルの管理] をご参照ください。

Apache Maven を使用して SDK をインポートする

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>cloudauth_intl20220809</artifactId>
  <version>2.0.2</version>
</dependency>

呼び出し例

import com.aliyun.cloudauth_intl20220809.Client;

import com.aliyun.cloudauth_intl20220809.models.EkycVerifyRequest;
import com.aliyun.cloudauth_intl20220809.models.EkycVerifyResponse;
import com.aliyun.teaopenapi.models.Config;


public class InitializeDemo {

    public static void main(String[] args) throws Exception {
        // クライアントを構築する
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
        Config config = new Config();
        config.setCredential(credentialClient);
        config.setEndpoint("cloudauth-intl.cn-hongkong.aliyuncs.com");
        config.setRegionId("cn-hongkong");
        Client client = new Client(config);


        // リクエストを構築する
        EkycVerifyRequest request = new EkycVerifyRequest();

        request.setMerchantBizId("***");
        request.setMerchantUserId("***");
        request.setIdOcrPictureUrl("***");
        request.setProductCode("eKYC_MIN");
        request.setDocType("00000001");
        request.setCrop("F");
        request.setAuthorize("T");
        request.setFacePictureUrl("***");
        request.setDocName("Huang***");
        request.setDocNo("360********");

        // API を呼び出す
        EkycVerifyResponse response = client.ekycVerify(request);

        // レスポンスから結果を取得する
        Integer statusCode = response.getStatusCode();
        String code = response.getBody().getCode();
        String passed = response.getBody().getResult().getPassed();
        String subCode = response.getBody().getResult().getSubCode();
        String transactionId = response.getBody().getResult().getTransactionId();
        String extIdInfo = response.getBody().getResult().getExtIdInfo();
        String extFaceInfo = response.getBody().getResult().getExtFaceInfo();


        System.out.println("statusCode:"+statusCode+"=== code:"+code +"==== transactionId:"+transactionId);
    }


}