Posting to a Chatter Feed
Posting to a Chatter Feed
The following code example shows a call to post an item to the context user’s Chatter feed.
1var sr = JSON.parse('<%=signedRequestJson%>');
2// Reference the Chatter user's URL from Context.Links object.
3var url = sr.context.links.chatterFeedsUrl+"/news/"+sr.context.user.userId+"/feed-items";
4var body = {body : {messageSegments : [{type: "Text", text: "Some Chatter Post"}]}};
5
6Sfdc.canvas.client.ajax(url,
7 {client : sr.client,
8 method: 'POST',
9 contentType: "application/json",
10 data: JSON.stringify(body),
11 success : function(data) {
12 if (201 === data.status) {
13 alert("Success");
14 }
15 }
16 });