Created
October 22, 2014 03:13
-
-
Save wendal/33e490c53d587351e681 to your computer and use it in GitHub Desktop.
演示用nutz调用yeelink的http api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void test_yeelink() { | |
String key = "my-key"; | |
String device_id = "12825"; | |
String sensor_id = "20872"; | |
Map<String, Object> data = new HashMap<String, Object>(); | |
data.put("value", 31.3); | |
String url = String.format("http://api.yeelink.net/v1.1/device/%s/sensor/%s/datapoints", device_id, sensor_id); | |
System.out.println("URL="+url); | |
Request req = Request.create(url, METHOD.POST); | |
req.setData(Json.toJson(data)); | |
req.getHeader().set("U-ApiKey", key); | |
Response resp = Sender.create(req).send(); | |
System.out.println(resp.getStatus()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment