全部产品

快速入门

更新时间:2020-12-18 17:52

以下用Java版SDK为您展示如何使用智能双录质检的API。

Java SDK示例

示例代码中的下列参数需要您根据实际情况自行填写。

  • <AccessKey>:您的AccessKeyId。获取方式请参见创建AccessKey

  • <AccessSecret>:您的AccessKeySecret。

  • <RegionId>:服务所在的地域ID,智能双录质检优先在金融云上架,可填入cn-shanghai-finance-1。

POM依赖

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-core</artifactId>
    <version>4.3.2</version>
</dependency>
<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-idrsservice</artifactId>
    <version>0.1.1</version>
</dependency>
Demo样例
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.idrsservice.model.v20200630.ListAppsRequest;
import com.aliyuncs.idrsservice.model.v20200630.ListAppsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.profile.DefaultProfile; 

public class ListAppsExample {

    private String accessKeyId = "<AccessKey>";
    private String accessSecret = "<AccessSecret>";
    private String regionId = "<RegionId>";

    public void listApps(){
        DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessSecret);
        IAcsClient client = new DefaultAcsClient(profile);

        CreateSnapshotRequest request = new CreateSnapshotRequest();
        request.setRegionId(regionId);
        try {
            ListAppsRequest request = new ListAppsRequest();
            request.setPageIndex(1);
            request.setPageSize(10);
            request.setProtocol(ProtocolType.HTTP);
            ListAppsResponse response = client.getAcsResponse(request);
            log.info(JSON.toJSONString(response));
        } catch (ServerException e) {
            log.info(String.format("Fail. Something with your connection with Aliyun go incorrect. ErrorCode: %s",
                e.getErrCode()));
        } catch (ClientException e) {
            log.info(
                String.format("Fail. Business error. ErrorCode: %s, RequestId: %s", e.getErrCode(), e.getRequestId()));
        }
    }

    public static void main(String[] args){
        new ListAppsExample().listApps();
    }
}