edit-icon download-icon

SDK manual

Last Updated: Feb 06, 2018

Currently, Alibaba Cloud provides SDKs in four languages: Java, Python, PHP, and C#. The following links provide the download, installation, and usage guide for each language:

If you want SDKs in other languages, select a third-party SDK service.

Quick start

Java

The following example describes how to install and use the Java SDK:

  1. On the Alibaba Cloud official website, create and manage your AccessKey.

  2. Install the SDK by using Maven.

    1. Add the Maven library.
      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>
    2. Add the JAR package dependency.
      1. <dependency>
      2. <groupId>com.aliyun</groupId>
      3. <artifactId>aliyun-java-sdk-domain-intl</artifactId>
      4. <version>1.0.0</version>
      5. </dependency>
      6. <dependency>
      7. <groupId>com.aliyun</groupId>
      8. <artifactId>aliyun-java-sdk-core</artifactId>
      9. <version>3.5.0</version>
      10. </dependency>
  3. Sample code. The following example submits bulk domain name registration tasks:

    1. import java.util.ArrayList;
    2. import com.aliyuncs.DefaultAcsClient;
    3. import com.aliyuncs.IAcsClient;
    4. import com.aliyuncs.domain_intl.model.v20171218.SaveBatchTaskForCreatingOrderActivateRequest;
    5. import com.aliyuncs.domain_intl.model.v20171218.SaveBatchTaskForCreatingOrderActivateRequest.OrderActivateParam;
    6. import com.aliyuncs.domain_intl.model.v20171218.SaveBatchTaskForCreatingOrderActivateResponse;
    7. import com.aliyuncs.exceptions.ClientException;
    8. import com.aliyuncs.exceptions.ServerException;
    9. import com.aliyuncs.profile.DefaultProfile;
    10. import com.aliyuncs.profile.IClientProfile;
    11. public class DomainSdkDemo {
    12. private static IAcsClient client = null;
    13. //Initialize the client.
    14. static {
    15. String regionId = "ap-southeast-1"; //Use the fixed value "ap-southeast-1" for the domain name SDK.
    16. String accessKeyId = ""; // your accessKey
    17. String accessKeySecret = "";// your accessSecret
    18. IClientProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret);
    19. // If the error message "Can not find endpoint to access" is returned, add the following code:
    20. // DefaultProfile.addEndpoint("ap-southeast-1", "ap-southeast-1", "Domain-intl", "domain-intl.aliyuncs.com");
    21. client = new DefaultAcsClient(profile);
    22. }
    23. public static void main(String[] args) {
    24. //Initialize the request.
    25. SaveBatchTaskForCreatingOrderActivateRequest request = new SaveBatchTaskForCreatingOrderActivateRequest();
    26. // request.setProtocol(ProtocolType.HTTPS); //Specify the access protocol.
    27. // request.setAcceptFormat(FormatType.JSON); //Specify the return format of the API.
    28. // request.setMethod(MethodType.POST); //Specify the request method.
    29. ArrayList<OrderActivateParam> list = new ArrayList<OrderActivateParam>();
    30. OrderActivateParam orderActivateParam = new OrderActivateParam();
    31. orderActivateParam.setDomainName("yourdomain.com");
    32. orderActivateParam.setRegistrantProfileId(0L);
    33. orderActivateParam.setEnableDomainProxy(false);
    34. orderActivateParam.setSubscriptionDuration(1);
    35. orderActivateParam.setPermitPremiumActivation(false);
    36. list.add(orderActivateParam);
    37. request.setOrderActivateParams(list);
    38. //Call the API and resolve the result.
    39. try {
    40. //IAcsClient provides two types of result returning. One is to call the doAction method to obtain the original API call result, that is, return the result of the HttpResponse type. The sample code is as follows:
    41. //HttpResponse httpResponse = client.doAction(describeCdnServiceRequest);
    42. //System.out.println(httpResponse.getUrl());
    43. //System.out.println(new String(httpResponse.getContent()));
    44. //Another is to call the getAcsResponse method to obtain the deserialized object. The sample code is as follows:
    45. SaveBatchTaskForCreatingOrderActivateResponse response = client.getAcsResponse(request);
    46. System.out.println(response.getTaskNo());
    47. } catch (ServerException e) {
    48. e.printStackTrace();
    49. } catch (ClientException e) {
    50. e.printStackTrace();
    51. }
    52. }
    53. }
Thank you! We've received your feedback.