REST API
最終更新日: 2024年7月15日
- トピック:
- スクリーンの開発
作成対象:
- 中級
- 開発者
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 を使用します。
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 を使用します。
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 を使用します。
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
recommendation-more-help
adce462a-f916-4dbe-9ab5-0b62cfb0f053