python上传数据至onenet

import requests
import json
import sys




DEVICEID = '*****'

SENSORID = 'humidity'

VALUE = 49

APIKEY = 'ZPdLy****'

url = 'http://api.heclouds.com/devices/%s/datapoints'%(DEVICEID)
print url
dict = {"datastreams":[{"id":"TEMP","datapoints":[{"value":50}]}]}
dict['datastreams'][0]['id'] = SENSORID
dict['datastreams'][0]['datapoints'][0]['value'] = VALUE
print dict
s = json.dumps(dict)
headers = {
                "api-key":APIKEY,
                "Connection":"close"

           }
r = requests.post(url,headers=headers,data = s)

print r.headers

print r.text

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭