Obtain an AccessKey pair
When you use OpenAPI Explorer to manage HTTPDNS, you need an AccessKey pair to call API operations. An AccessKey pair consists of an AccessKey ID and an AccessKey secret.
To ensure the security of cloud services, you must create a RAM user, obtain an AccessKey pair of the RAM user, and then manage HTTPDNS as the RAM user by using OpenAPI Explorer. Perform the following steps:
Create a RAM user. For more information, see
Grant permissions on HTTPDNS to the RAM user. For more information, see Grant permissions to a RAM user.
Obtain the AccessKey pair of the RAM user. For more information, see Obtain an AccessKey pair.
NoteAn AccessKey pair consists of an AccessKey ID and an AccessKey secret.
Add dependencies
You can add Maven dependencies:
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-httpdns</artifactId>
<version>2.1.2</version>
</dependency>
You can also download JAR packages:
Sample code
import com.aliyuncs.http.HttpResponse;
import com.aliyuncs.httpdns.model.v20160201.*;
import com.aliyuncs.profile.*;
import com.aliyuncs.*;
public class DemoListDomains {
public static void main(String[] args) {
String accessKeyId = ""; /* Access Key ID */
String accessKeySecret = ""; /* Access Key Secret */
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
IAcsClient client = new DefaultAcsClient(profile);
ListDomainsRequest request = new ListDomainsRequest();
try {
ListDomainsResponse httpResponse = client.getAcsResponse(request);
System.out.println(httpResponse.getRequestId());
}catch (Exception e) {
e.printStackTrace();
}
}
}