本示例介绍如何使用Alibaba Cloud SDK for Java调用DescribeLiveSnapshotConfig接口查询域名下截图配置。

前提条件

请在pom.xml文件中增加以下依赖,准确的SDK版本号,参见 阿里云开发工具包(JavaSDK)

<dependency>
    <groupId>com.aliyun</groupId>
    <artifactId>aliyun-java-sdk-live</artifactId>
    <version>3.7.5</version>
 </dependency>

示例代码

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.live.model.v20161101.DescribeLiveSnapshotConfigRequest;
import com.aliyuncs.live.model.v20161101.DescribeLiveSnapshotConfigResponse;
import com.aliyuncs.profile.DefaultProfile;
import com.google.gson.Gson;

public class TestDescribeLiveSnapshotConfig {

    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile(
                "<your-region-id>", // 地域ID
                "<your-access-key-id>", // 您的AccessKey ID
                "<your-access-key-secret>"); // 您的AccessKey Secret
        IAcsClient client = new DefaultAcsClient(profile);

        DescribeLiveSnapshotConfigRequest request = new DescribeLiveSnapshotConfigRequest();
        // 直播流所属应用名称
        request.setAppName("testApp");
        // 您的加速域名
        request.setDomainName("www.yourDomainName.com");
        // 排序方式 :asc 升序,desc降序。默认,desc
        request.setOrder("asc");
        // 分页页码  默认1
        request.setPageNum(1);
        // 每页显示数量,默认为10
        request.setPageSize(5);

        try {
            DescribeLiveSnapshotConfigResponse response = client.getAcsResponse(request);
            System.out.println(new Gson().toJson(response));
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            System.out.println("ErrCode:" + e.getErrCode());
            System.out.println("ErrMsg:" + e.getErrMsg());
            System.out.println("RequestId:" + e.getRequestId());
        }

    }

}
说明 更多参数信息,请参见API参考