No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
アクションリンクを定義して投稿する
アクションリンクを作成して投稿する場合、アクションリンクを定義し、アクションリンクグループを定義してから、アクションリンクグループをフィード項目に関連付ける必要があります。この例では、各ステップを順に説明します。
ステップ 1: アクションリンクを定義する
アクションリンクはフィード項目のボタンと考えます。ボタンのように、アクションリンクには表示ラベル (labelKey) があります。アクションリンク定義には、URL (actionUrl) や HTTP メソッド (method) のほか、省略可能なリクエストボディ (requestBody) や HTTP ヘッダー (headers) など、他にもプロパティがあります。
アクションリンク定義は常に、アクションリンクグループ定義内にネストされます。この例では、定義したアクションリンクがステップ 2 のアクションリンクグループ定義内にネストされています。
- リクエストボディ
- Action Link Definition Input
- リクエストボディの例
-
1{ 2 "actionType":"Api", 3 "actionUrl":"/services/data/v31.0/chatter/feed-elements", 4 "groupDefault":"true", 5 "labelKey":"Post", 6 "method":"Post", 7 "requiresConfirmation":"true", 8 "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"Testing a post created via an API action link.\"}]}}", 9 "headers":[ 10 { 11 "name":"Content-Type", "value":"application/json" 12 }] 13}
ユーザがこのアクションリンクをクリックすると、Chatter REST API に対して HTTP POST 要求が実行され、フィード項目が Chatter に投稿されます。requestBody プロパティは、新しいフィード項目のテキストなど、actionUrl リソースのリクエストボディを保持します。この例では、新しいフィード項目にテキストしか含まれていませんが、添付ファイルやアンケートなどの他の機能やアクションリンクも含めることができます。
ステップ 2: アクションリンクグループを定義する
ラジオボタンと同様に、アクションリンクはグループ内にネストする必要があります。グループ内のアクションリンクは、グループのプロパティを共有し、相互に排他的です (クリックできるのは、グループ内の 1 つのアクションリンクのみです)。定義したアクションリンクが 1 つだけの場合でも (ステップ 1 の例と同様)、アクションリンクグループ内にネストする必要があります。
- リソース
- /connect/action-link-group-definitions
- HTTP メソッド
- POST
- リクエストボディ
- Action Link Group Definition Input
このリクエストボディには、ステップ 1 でネストした Action Link Definition Input リクエストボディを保持する actionLinks プロパティがあります。複数のアクションリンクを定義した場合は、そのすべてをこのプロパティに含めます。
- リクエストボディの例
-
1POST /services/data/v31.0/connect/action-link-group-definitions?pilotKey=R002AUMQV3GN 2 3{ 4 "executionsAllowed":"OncePerUser", 5 "expirationDate":"2014-09-20T19:32:10+0000", 6 "category":"Primary", 7 "actionLinks":[ 8 { 9 "actionType":"Api", 10 "actionUrl":"/services/data/v31.0/chatter/feed-elements", 11 "groupDefault":"true", 12 "labelKey":"Post", 13 "method":"Post", 14 "requiresConfirmation":"true", 15 "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"This is a test post created via an API action link.\"}]}}", 16 "headers":[ 17 { 18 "name":"Content-Type", "value":"application/json" 19 }] 20 }] 21} - cURL を使用した要求の例
- cURL を使用して要求を実行するには、次のように入力し、Developer Edition インスタンス名、パイロットキー、および OAuth 情報を置き換えます。
1curl -H "X-PrettyPrint: 1" -H "Content-Type: application/json" -d '{ "executionsAllowed":"OncePerUser", "expirationDate":"2014-09-20T19:32:10+0000", "category":"Primary", "actionLinks":[ { "actionType":"Api", "actionUrl":"/services/data/v31.0/chatter/feed-elements", "groupDefault":"true", "labelKey":"Post", "method":"Post", "requiresConfirmation":"true", "requestBody":"{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"This is a test post created via an API action link.\"}]}}", "headers":[ { "name":"Content-Type", "value":"application/json" }] }] }' -X POST "https://instance_name/services/data/v31.0/connect/action-link-group-definitions?pilotKey=R002AUMQV3GN" -H 'Authorization: OAuth 00DRR0000000N0g!RWaPj94O6yOD.lfjB9LqMk' --insecure - レスポンスボディ
- Action Link Group Definition
ステップ 3: アクションリンクグループをフィード項目に関連付けて投稿する
- リソース
- /chatter/feed-elements
- HTTP メソッド
- POST
- リクエストボディ
- Feed Item Input
- リクエストボディの例
-
ステップ 2 の Action Link Group Definition レスポンスの id からアクションリンクグループ ID を取得します。
1POST /services/data/v31.0/chatter/feed-elements 2 3{ 4 "body": { 5 "messageSegments": [ 6 { 7 "type": "Text", 8 "text": "Click to post a feed item." 9 } 10 ] 11 }, 12 "subjectId": "me", 13 "feedElementType": "feedItem", 14 "capabilities": { 15 "associatedActions": { 16 "actionLinkGroupIds": ["0AgRR0000004CTr0AM"] 17 } 18 } 19} - cURL を使用した要求の例
- cURL を使用して要求を実行するには、次のように入力し、ステップ 2 で返された アクションリンクグループ ID、Developer Edition インスタンス名、および OAuth 情報を置き換えます。
1curl -H "X-PrettyPrint: 1" -H "Content-Type: application/json" -d '{ "body": { "messageSegments": [ { "type": "Text", "text": "Click to post a feed item." } ] }, "subjectId": "me", "feedElementType": "feedItem", "capabilities": { "associatedActions": { "actionLinkGroupIds": ["0AgRR0000004CTr0AM"] } } }' -X POST "https://instance_name/services/data/v31.0/chatter/feed-elements" -H 'Authorization: OAuth OOARoAQETAKEIddnMWXh462dprYAgRWaPj94O6yOD' --insecure - レスポンスボディ
- Feed Item