Step By Step
1、服务开通地址
2、创建项目
3、控制台快速校验测试
4、pom.xml
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-address-purification</artifactId>
<version>1.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.aliyun/aliyun-java-sdk-core -->
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>4.5.6</version>
</dependency>
5、地址标准化SDK Code Sample
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.address_purification.model.v20191118.ClassifyPOIRequest;
import com.aliyuncs.address_purification.model.v20191118.ClassifyPOIResponse;
import com.aliyuncs.profile.DefaultProfile;
public class AddressPurificationTestApp {
public static void main(String[] args) throws ClientException {
// AccessKey,AccessSecret获取参考链接:https://developer.aliyun.com/article/693979?spm=a2c6h.13262185.0.0.28695eb5HCba5B
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou",
"******",
"******");
IAcsClient client = new DefaultAcsClient(profile);
ClassifyPOIRequest request = new ClassifyPOIRequest();
request.setServiceCode("addrp");
request.setAppKey("d6qs********");
request.setText("杭州市文一西路969号");
// request.setDefaultProvince("浙江省");
// request.setDefaultCity("杭州市");
// request.setDefaultDistrict("余杭区");
ClassifyPOIResponse response = client.getAcsResponse(request);
System.out.println(response.getData());
}
}
6、Java Core SDK Code Sample
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
public class AddressPurificationByCoreSDK {
public static void main(String[] args) {
// AccessKey,AccessSecret获取参考链接:https://developer.aliyun.com/article/693979?spm=a2c6h.13262185.0.0.28695eb5HCba5B
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou",
"******",
"******");
IAcsClient client = new DefaultAcsClient(profile);
CommonRequest commonRequest = new CommonRequest();
commonRequest.setSysAction("ClassifyPOI");
commonRequest.setSysMethod(MethodType.POST);
commonRequest.setSysVersion("2019-11-18");
commonRequest.setSysDomain("address-purification.cn-hangzhou.aliyuncs.com");
commonRequest.putBodyParameter("AppKey","d6qs******");
commonRequest.putBodyParameter("ServiceCode","addrp");
commonRequest.putBodyParameter("Text","杭州市文一西路969号");
CommonResponse response = null;
try {
response = client.getCommonResponse(commonRequest);
} catch (ClientException e) {
e.printStackTrace();
}
System.out.println(response.getData());
}
}