閱讀465 返回首頁    go 人物


JAVA-SDK__點播SDK_SDK手冊_視頻點播-阿裏雲

SDK-JAVA

  • 環境要求

    Java 6+

    Maven

  • 安裝

    • 添加maven倉庫

      1. <repositories>
      2. <repository>
      3. <id>sonatype-nexus-staging</id>
      4. <name>Sonatype Nexus Staging</name>
      5. <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
      6. <releases>
      7. <enabled>true</enabled>
      8. </releases>
      9. <snapshots>
      10. <enabled>true</enabled>
      11. </snapshots>
      12. </repository>
      13. </repositories>
    • 添加Jar包依賴

      1. <dependency>
      2. <groupId>com.aliyun</groupId>
      3. <artifactId>aliyun-java-sdk-core</artifactId>
      4. <version>3.0.6</version>
      5. </dependency>
      6. <dependency>
      7. <groupId>com.aliyun</groupId>
      8. <artifactId>aliyun-java-sdk-mts</artifactId>
      9. <version>2.1.7</version>
      10. </dependency>
  • 多區域支持

    添加北京區域(其他區域類似):

    1. import com.aliyuncs.profile.DefaultProfile;
    1. DefaultProfile.addEndpoint("cn-beijing",
    2. "cn-beijing",
    3. "Mts",
    4. "mts.cn-beijing.aliyuncs.com");
    • API調用示例

      下麵以SearchMediaWorkflowAPI調用為例。

      1. import com.aliyuncs.DefaultAcsClient;
      2. import com.aliyuncs.exceptions.ClientException;
      3. import com.aliyuncs.exceptions.ServerException;
      4. import com.aliyuncs.mts.model.v20140618.SearchMediaWorkflowRequest;
      5. import com.aliyuncs.mts.model.v20140618.SearchMediaWorkflowResponse;
      1. SearchMediaWorkflowResponse searchMediaWorkflow(DefaultAcsClient client) {
      2. SearchMediaWorkflowRequest request = new SearchMediaWorkflowRequest();
      3. SearchMediaWorkflowResponse response = null;
      4. try {
      5. response = client.getAcsResponse(request);
      6. } catch (ServerException e) {
      7. throw new RuntimeException("SearchMediaWorkflowRequest Server failed");
      8. } catch (ClientException e) {
      9. throw new RuntimeException("SearchMediaWorkflowRequest Client failed");
      10. }
      11. return response;
      12. }
    • 杭州區域

      隻要初始化profile和client時,正確設置RegionId參數”cn-hangzhou”,API調用時無需特殊設置。

      1. import com.aliyuncs.profile.DefaultProfile;
      2. import com.aliyuncs.DefaultAcsClient;
      1. DefaultProfile profile = DefaultProfile.getProfile(
      2. "cn-hangzhou",
      3. accessKeyId,
      4. accessKeySecret);
      5. DefaultAcsClient client = new DefaultAcsClient(profile);
      6. searchMediaWorkflow(client);
    • 北京區域

      隻要初始化profile和client時,正確設置RegionId參數”cn-beijing”,API調用時無需特殊設置。

      1. import com.aliyuncs.profile.DefaultProfile;
      2. import com.aliyuncs.DefaultAcsClient;
      1. DefaultProfile profile = DefaultProfile.getProfile(
      2. "cn-beijing",
      3. accessKeyId,
      4. accessKeySecret);
      5. DefaultAcsClient client = new DefaultAcsClient(profile);
      6. searchMediaWorkflow(client);

最後更新:2016-11-23 18:24:22

  上一篇:go 多區域支持__點播SDK_SDK手冊_視頻點播-阿裏雲
  下一篇:go PHP-SDK__點播SDK_SDK手冊_視頻點播-阿裏雲