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