magic-api
Thingsboard
ChuDaYunPing
Thingsboard物联平台获取遥测数据接口
import org.ssssssss.script.parsing.ast.statement.Return
import http;
// 获取IOT令牌
var token=http.connect('http://host:8080/api/auth/login').body({"username":"wushuo@88.com","password":"11111"}).contentType('application/json').post().getBody();
//获取实时数据
var itmph=http.connect('http://host:8080/api/plugins/telemetry/DEVICE/1e5f38e0-3a6c-11ee-88f7-43d5d3aef328/values/timeseries').header("X-Authorization", "Bearer "+token.token).contentType('application/json').get().getBody();
//数据重组为简单格式
var retList = [];
retList.push({
"time":itmph.ts.value,
"wendu":itmph.tem.value,
"PH":itmph.PH.value,
"lon":itmph.lon.value,
"lat":itmph.lat.value
})
return retList;
蓝天采集器接口
import cn.hutool.http.HttpUtil
import log;
import 'java.lang.System' as System;
var url = "http://host/index.php?s=/api_task/13/zjb_jsyw";
var values = {
}
var resp2 = HttpUtil.post(url,values) .header("Content-Type", "application/json");
var respObj2 = resp2::json;//响应结果为json字符串,将字符串转换为json对象
var retList = [];
for(index,item in respObj2){ //如果不需要index,也可以写成for(item in list)
retList.push({
"url":item.url,
"标题":item.fields.标题.value,
"来源":item.fields.来源.value,
"发布时间":item.fields.发布时间.value,
"正文":item.fields.正文.value
})
}
return retList;