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

阅读更多
想对作者说点什么?

博主推荐

换一批

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