2017-09-22 21 views

답변

1

urequests 라이브러리를 사용하여 HTTP 요청을 보낼 수 있습니다.

curl -X POST -H "Content-Type: application/json" -d '{"temperature": 10, "luminosity": {"value":10}, "wind_speed": [{"value": 11, "timestamp":10000}, {"value": 12, "timestamp":13000}]}' http://things.ubidots.com/api/v1.6/devices/weather-station?token=your_api_token. 

이 같은 MicroPython로 변환 할 수

import urequests 
import json 

headers = { 
    'Content-Type': 'application/json', 
} 

data = '{"temperature": 10, "luminosity": {"value":10}, "wind_speed": [{"value": 11, "timestamp":10000}, {"value": 12, "timestamp":13000}]}' 

# replace weather-station with your device name, and api-token with your api-token 
r = urequests.post('http://things.ubidots.com/api/v1.6/devices/weather-station?token=your_api_token', headers=headers, data=data).json() 
print(r) 

응답은 HTTP 각 변수에 대한 상태 코드를 포함, :로 ubidots 문서 당으로 는 데이터가 전송 될 수있다.