Hue API无法通过浏览器命令行点亮

时间:2015-07-26 14:39:05

标签: json url philips-hue

我尝试使用Clip API调试工具打开我的Hue Lamp(如下所述:http://www.developers.meethue.com/documentation/getting-started),一切正常。

现在我想在浏览器命令行上做同样的事情,我不知道如何编写网址。我尝试了一些变化但没有效果......

网址应如下所示: http://192.168.0.18/api/MyHashcode/lights/2/state { “上的”:真}&安培;模式=放

问题是messagebody(上面的链接)中显示的json代码,我不知道如何将其嵌入到url中。如何才能使这个工作正常?

提前致谢, 姬

1 个答案:

答案 0 :(得分:0)

为了修改灯光状态,您必须使用PUT方法,其中JSON有效负载位于HTML请求的BODY中。您不能将JSON放在URL查询字符串中。

但是,您可以使用多种语言将JSON发送到网桥。以下是使用AppleScript的示例:

-- define baseUrl to point to your Hue hub address and one of the keys in your whitelist
set baseUrl to " http://YOUR-HUB-IP/api/YOUR-WHITELIST-ENTRY"

-- define some JSON to set a light state
set lightStateOn to the quoted form of " {\"on\": true,\"bri\": 254,\"hue\": 8000,\"sat\": 254} "

-- send the JSON to set a light state (on and with specified hue, saturation, and brightness)
do shell script "curl --request PUT --data " & lightStateOn & baseUrl & "/lights/1/state/"
相关问题