Beruflich Dokumente
Kultur Dokumente
Cheat Sheet
Collaboration
Overview
Add Comments
The Chatter REST API provides access to Chatter feeds and social data such as users,
groups, and followers, via a standard JSON/XML-based API.
To add a comment to a feed item, use the comments resource with POST and the request
parameter text. As part of the comments resource, you must also specify the feed item
that you are adding the comment to.
All Chatter API resources are accessed using a base URI for your company, version
information, and the named resource. For example, if the base URI is this:
https://na1-salesforce.com
And the version information is this:
/services/data/v22.0/chatter
And youre using the following resource:
/feeds/news/me/feed-items
Put together, the full URL to the resource is:
https://na1-salesforce.com/services/data/v22.0/chatter/feeds/news/
me/feed-items
/feed-items/0D5D0000000DaSbKAK/comments?text=New+post
Follow Records
Use the users resource to follow a specific record. A record can be any object in
Salesforce, such as a custom record, a file, a user, and so on.
To follow a record, use POST with the subjectId request parameter. This example follows
a user:
Authentication
/users/me/following?subjectId=005D0000001GpHp
Chatter API uses OAuth 2.0 for authentication. The return from a successful authentication
includes an access token, which can be used for subsequent calls to the Chatter API
resources.
Unfollow Records
Resources
The following resources are available:
Resource
Description
/comments
/feed-items
/feeds/news
Use the subscriptions resource to unfollow a record. You must use the subscription ID
with the subscriptions resource. To get subscription IDs, use the following resource:
/users/me | userID/following
To unfollow a record, use DELETE. For example:
/subscriptions/0E8D00000001JkFKAU
Feeds Resources
Chatter API resources represent many feed types, such as news feeds, user-profile feeds,
group feeds, and so on.
Most feeds can be accessed with either the keyword me or a specified user ID, such as
005D0000001GLowIAN. In addition, all feeds have a top-level resource that returns a URL
of the feed items for that feed. For example:
/feeds/record
/feeds/to
/feeds/files/me
/feeds/groups/me
/feeds/user-profile/005D0000001GLowIAN
/feeds/user-profile
All feeds have a feed-items resource that returns the feed items for that feed. For
example, to return the feed items for the current users news feed, use GET and the
following resource:
/group-memberships
/feeds/news/me/feed-items
/groups
The specified group. This is not a feed. To get the feed for a
group, use the record resource.
Groups
/likes
/subscriptions
/users
Chatter API has the following resources for working with groups:
/groups returns information about the specified group, such as members in the group,
the group photo, and so on
/group-memberships returns information about the specified member of a group
To get a list of all the groups the current signed-in user is a member of, use GET with the
following resource:
/groups
To add a member to a specific group, use the groups resource and POST with the group
ID, the memberID request parameter, and the specified user ID. For example:
To like a feed item, use the likes resource with POST. As part of the likes resource, you
must also specify the feed item that you are adding the like to.
/groups/0F9D000000006bOKAQ/members?memberId=005D0000001GLowIAB
The following example adds a like to an existing feed item, which has an ID of
0D5D0000000DaZBKA0.
/feed-items/0D5D0000000DaZBKA0/likes
To post to a specific group, use the /feeds/record resource and POST with the group
ID, and the text request parameter. For example:
/feeds/record/0F9D000000006bO/feed-items
?text=Has+everyone+seen+the+latest+building+proposal?
http://sfdcgurukul.blogspot.com
Message Segments
Pagination
Message segments are returned as part of the body of a feed item. Each message segment
contains the formatted text of the feed item, as well as information about the type of feed
item.
Feeds, lists of groups or records a user is following, and other resources may return more
items than can be contained in a single page. The return for all of these collections contains
both a currentPageUrl and a nextPageUrl property. The currentPageUrl contains
a URL that points to the current page of items, while the nextPageUrl contains the URL
for the next page of items.
Any feed item can be composed by rendering the list of message segments in the given
order. Rendering a message segment is as easy as displaying the text property. For
example:
<xml parsing psuedo code>
StringBuilder feedItemText = new StringBuilder();
NodeList nodes = feedItemElement.getElementsByTagName("body").
item(0).firstChild().getChildNodes();
for(int i=0; i<nodes.getLength(); i++) {
Node nextNode = nodes.item(0);
if(!nextNode instanceof Element) {
continue;
}
someWriter.write(feedItemText);
</xml parsing psuedo code>
"currentPageUrl": "/services/data/v22.0/chatter/feeds/
news/005x0000001j2OwAAI/feed-items",
. . .
"nextPageUrl": "/services/data/v22.0/chatter/feeds/
news/005x0000001j2OwAAI/feed-items?page=2011-07-01T14%3A11%3A54Z%2
C0D5x0000001NUGICA4"
}
The second page of items contains a new value for nextPageUrl. To page through the
feed items, use the URL from each subsequent page. There are no more pages when
nextPageUrl is null.
http://sfdcgurukul.blogspot.com