0

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

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

网址应如下所示:http: //192.168.0.18/api/MyHashcode/lights/2/state {"on":true}&mode=put

问题是消息正文中显示的 json 代码(上面的链接),我不知道如何将其嵌入 url。正确的语法如何使它工作?

在此先感谢, 基

4

1 回答 1

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/"
于 2016-05-04T03:31:03.963 回答