准备工作

更新时间:2018-06-08 12:03:45

云端服务调用流程

阿里云IoT云端资源需要云端资源令牌访问。云端资源令牌通过开通云端资源服务获取,云端管理默认开通。
主要流程如下:

image.png | left | 657x397

获取云端唯一身份AppKey

image.png | center | 830x295

调用示例

// https://github.com/aliyun/iotx-api-gateway-client
public static void main(String[] args) throws UnsupportedEncodingException {
    SyncApiClient syncClient = SyncApiClient.newBuilder()
        .appKey("你的<AppKey>")
        .appSecret("你的<AppSecret>")
        .build();

    IoTApiRequest request = new IoTApiRequest();
    //设置api的版本
    request.setApiVer("1.0.0");
    request.setCloudToken("CloudTokenXXXXX");

    //设置接口的参数
    request.putParam("grantType", "project");
    request.putParam("res", "xxxxx");

    //请求参数域名、path、request
    ApiResponse response = syncClient.postBody("api.link.aliyun.com",
        "/cloud/token", request, true);
    System.out.println(
        "response code = " + response.getStatusCode() + " response content = " + new String(response.getBody(),
            "utf-8"));
}

results matching ""

    No results matching ""