前言:
此时姐妹们对“java openapi”大体比较看重,你们都想要学习一些“java openapi”的相关文章。那么小编也在网络上网罗了一些关于“java openapi””的相关内容,希望大家能喜欢,姐妹们快快来了解一下吧!简介: 物联网平台云端SDK用于调用云端API,以实现物联网平台的云端能力,如产品管理、设备管理、Topic管理、数据流转规则管理、消息通信等。 (本文示例以Common sdk 和 云端sdk)。
1、通过Common sdk调用
pom.xml
JavaDemo
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;
public class RegisterDevice {
public static void main(String[] args) { DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<accessKeyId>", "<accessSecret>"); IAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); request.setSysMethod(MethodType.POST); request.setSysDomain("iot.cn-shanghai.aliyuncs.com"); request.setSysVersion("2018-01-20"); request.setSysAction("RegisterDevice"); request.putQueryParameter("RegionId", "cn-shanghai"); request.putQueryParameter("ProductKey", "a1dkPFDXTA4"); request.putQueryParameter("DeviceName", "lebron"); try { CommonResponse response = client.getCommonResponse(request); System.out.println(response.getData()); } catch (ServerException e) { e.printStackTrace(); } catch (ClientException e) { e.printStackTrace(); }}
}
测试结果
标签: #java openapi