本示例介绍使用Alibaba Cloud SDK for Java调用CopyCaster接口复制导播台。

前提条件

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

阿里云2000元代金券免费领,最新优惠1折抢购,2核4G云服务器仅799元/3年,新老用户同享,立即抢购>>>

<dependency&gt;     <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.CopyCasterRequest; import com.aliyuncs.live.model.v20161101.CopyCasterResponse; import com.aliyuncs.profile.DefaultProfile; import com.google.gson.Gson;  /**  * 复制导播台  */ public class TestCopyCaster {      public static void main(String[] args) {         DefaultProfile profile = DefaultProfile.getProfile(                 "<your-region-id>", // 地域ID                 "<your-access-key-id>", // 您的AccessKeyId                 "<your-access-key-secret>");// 您的AccessKeySecretId         IAcsClient client = new DefaultAcsClient(profile);          CopyCasterRequest request = new CopyCasterRequest();         // 用于保证请求的幂等性。由客户端生成该参数值,要保证在不同请求间唯一,最大不值过 64 个 ASCII 字符。         request.setClientToken("yourClientToken");         // 新导播台名称         request.setCasterName("yourNewCasterName");         // 原导播台Id         request.setSrcCasterId("yourSrcCasterId");          try {             // 处理请求并获取返回值             CopyCasterResponse 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());         }     } }