AEM Screens提供了遵循Siren规范的简单RESTful API。 它允许导航内容结构并将命令发送到环境中的设备。
API可在http://localhost:4502/api/screens.json访问。
API返回的JSON调用与当前资源相关的实体的列表。 在列出的自我链接后,这些实体中的每个实体都可再次作为REST资源访问。
例如,要访问演示旗舰位置的显示屏,您可以调用:
GET /api/screens/content/screens/we-retail/locations/demo/flagship.json HTTP/1.1
Host: http://localhost:4502
或使用卷起:
curl -u admin:admin http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship.json
结果会是:
{
"class": [
"aem-io/screens/location"
],
"links": [
{
"rel": [
"self"
],
"href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship.json"
},
{
"rel": [
"parent"
],
"href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo.json"
}
],
"properties": {…},
"entities": [
{
"class": [
"aem-io/screens/display"
],
"links": [
{
"rel": [
"self"
],
"href": "http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json"
}
],
"rel": [
"child"
],
"properties": {
"title": "Single Screen Display",
"height": 1440,
"description": "Demo location of a single screen display.",
"name": "single",
"width": 2560,
"idletimeout": 300,
"layoutrows": 1,
"layoutcols": 1
}
},
…
]
}
然后,要访问“单屏显示”,您可以调用:
GET /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502
API调用返回的JSON可包含资源上可用的一列表操作。
例如,显示屏列表broadcast-command动作,允许向分配给该显示屏的所有设备发送命令。
GET /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502
或使用卷起:
curl -u admin:admin http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json
结果:
{
"class": [
"aem-io/screens/display"
],
"links": […],
"properties": {…},
"entities": […],
"actions": [
{
"title": "",
"name": "broadcast-command",
"method": "POST",
"href": "/api/screens/content/screens/we-retail/locations/demo/flagship/single",
"fields": [
{
"name": ":operation",
"value": "broadcast-command",
"type": "hidden"
},
{
"name": "msg",
"type": "text"
}
]
}
]
}
要触发此操作,应调用:
POST /api/screens/content/screens/we-retail/locations/demo/flagship/single.json HTTP/1.1
Host: http://localhost:4502
:operation=broadcast-command&msg=reboot
或使用卷起:
curl -u admin:admin -X POST -d ':operation=broadcast-command&msg=reboot' http://localhost:4502/api/screens/content/screens/we-retail/locations/demo/flagship/single.json