触达云屏magic-api对接其他数据源系统示例(笔记)

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;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值