- IUYUN OPEN SDK for Java 需要1.6以上的JDK。
如果您使用Apache Maven来管理Java项目,只需在项目的pom.xml
文件加入相应的依赖项即可。
<dependency>
<groupId>com.iuyun</groupId>
<artifactId>open-sdk</artifactId>
<version>1.0.2</version>
</dependency>
以下这个代码示例向您展示了调用 IUYUN OPEN SDK for Java 的3个主要步骤:
- 创建Client实例并初始化。
- 创建API请求并设置参数。
- 发起请求并处理应答或异常。
package com.testprogram;
import com.iuyun.open.config.Config;
import com.iuyun.open.domain.Client;
import com.iuyun.open.model.request.collection.BatchCollectDataRequest;
import com.iuyun.open.model.request.collection.CollectDataRequest;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
// 创建Client实例并初始化
Config config = Config.build(
"<your-app-id>", // IU云为企业分配的 APPID
"<your-secret>", //IU云的SECRET
"<your-endpoint>"); //"api.iuindustry.com"
Client client = new Client(config);
//上传单个
CollectDataRequest request = new CollectDataRequest();
request.setDataCode("001");
request.setDataTime("2021-12-26 20:48:10");
request.setStatisticsValue("1");
client.collectData(request);
//批量上传
CollectData data1 = new CollectDataImpl();
data1.setDataCode("001");
data1.setDataTime("2021-12-26 20:48:10");
data1.setStatisticsValue("1");
CollectData data2 = new CollectDataImpl();
data2.setDataCode("002");
data2.setDataTime("2021-12-26 20:49:10");
data2.setStatisticsValue("2");
BatchCollectDataRequest batchRequest = new BatchCollectDataRequest(
Arrays.asList(data1,data2)
);
client.batchCollectData(batchRequest);
}
}
每个版本的详细更改记录在发行说明中。
Copyright (c) 2017-present, Innovation & Union Technology Co.,Ltd. All rights reserved.