本文为您介绍了在使用接口前你需要做的准备工作和示例参考。

开发准备

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-core</artifactId>
  <version>4.4.8</version>
</dependency>

<dependency>
  <groupId>com.aliyun</groupId>
  <artifactId>aliyun-java-sdk-aiccs</artifactId>
  <version>1.1.3</version>
</dependency>

JAVA-SDK代码示例

说明 instanceId为阿里云开通实例ID,可在智能联络中心阿里云控制台查询。
DefaultProfile profile = DefaultProfile.getProfile("", accessKey, accessSecret);
IAcsClient client = new DefaultAcsClient(profile);

GetAgentRequest request = new GetAgentRequest();
request.setRegionId("cn-shanghai");
request.setEndpoint("aiccs.aliyuncs.com");
request.setInstanceId("agent_12345");
request.setAccountName("hellouser");

try {
    GetAgentResponse response = client.getAcsResponse(request);
    System.out.println(JSON.toJSONString(response));
}
catch (Exception e) {
    e.printStackTrace();
}

通用请求代码示例

说明 instanceId为阿里云开通实例ID,可在智能联络中心阿里云控制台查询。
DefaultProfile profile = DefaultProfile.getProfile("", accessKey, accessSecret);
IAcsClient client = new DefaultAcsClient(profile);

CommonRequest request = new CommonRequest();
request.setMethod(MethodType.POST);
request.setDomain("aiccs.aliyuncs.com");
request.setVersion("2019-10-15");
request.setAction("GetAgent");                            // ApiCode
request.putBodyParameter("InstanceId", "agent_12344");    // 参数-InstanceId
request.putBodyParameter("AccountName", "12345");        // 参数-AccountName
try {  
    CommonResponse response = client.getCommonResponse(request);
    System.out.println(JSON.toJSONString(response));
} catch (Exception e) {
    e.printStackTrace();
}