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

你可能感兴趣的:(python上传数据至onenet)