Chatter REST API Overview - Amazon S3 · Chatter REST API Overview . ... Use Cases – Intranet &...

42
Chatter REST API Overview

Transcript of Chatter REST API Overview - Amazon S3 · Chatter REST API Overview . ... Use Cases – Intranet &...

Chatter REST API Overview

Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non-salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2011. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.

Agenda

§  Why Chatter is important for developers §  Chatter REST API Use Cases

§  API Walk Through

§  Example Code

§  Q&A and application ideas

WHY CHATTER API?

Why the Chatter API – for IT

§  Make your applications social –  Better communication between silos and teams vs.

email

–  Build a searchable tribal knowledge base on your intranet

Why Chatter – for independent software vendors

§  Chatter is the news feed for the enterprise

§  Distribute your application virally in the feed.

§  Make your application social

§  Add functionality with minimal work –  Feeds, likes, comments

–  Groups

–  Mobile and desktop

Use Cases - Mobile

§  Build custom mobile applications, e.g. –  Product information apps –  Q&A

–  Note taking and case discussion for medical providers

http://github.com/cseymourSF

Use Cases – Intranet & Sharepoint

§  Add social interaction to document sharing and other external systems.

§  Move internal customer interaction into a group based queue

§  Push notifications of changes/updates into chatter.

http://chatter-intranet.heroku.com

Use Cases – Independent Software Vendors

§  Viral distribution

§  Social interaction §  Notifications

WALKTHROUGH

Introduction

§  The Chatter API is a REST-ful web service that exposes a corporation’s social data.

§  The Chatter API is hosted by Salesforce and uses OAuth2 for authentication

Chatter API Resources

§  Users –  Includes followers, following

§  Groups –  Includes members

§  Feed –  Includes comments, likes

§  Records –  Includes followers

§  Private Messages

§  Trending Topics

§  Recommendations

Chatter API or SObject REST API?

§  Chatter API provides: –  Localized data

–  All the feed data in 1 request –  Data matching what is shown in the web UI

–  Semantically rich resources

§  SObject REST API provides: –  Data directly from the database –  Arbitrary SOQL queries

§  You can mix and match - use the same OAuth tokens to access both

Authentication with OAuth2

§  Peace of mind for users: –  Authenticate through a standard Salesforce login site

–  Apps don’t need to cache a user’s login credentials –  Users can revoke authorization for an app later on

§  Info on using OAuth2 can be found on DeveloperForce

Authenticating and Authorizing

User Authentication App Authorization

Authorizing a Chatter API request

§  Oauth access token is used in the “Authorization” header of a Chatter API request:

Chatter API URLs

<instance URL> + “/services/data/v23.0” + <relative path> + <query string>

§  For example:

http://na11.salesforce.com/services/data/v23.0/chatter/users/00500C23498934

Chatter API Requests

§  An app can request to access and modify social enterprise data: –  Getting the news feed:

•  GET /chatter/feeds/news/me

–  Removing a feed item: •  DELETE /chatter/feed-items/005Q00593948398

–  Following a record: •  POST /chatter/users/me/following&subjectId=00500C23498934

Chatter API Responses

§  Response can be provided in JSON or XML format §  Response gives a “representation” holding one of:

–  requested data

–  confirmation that an operation has completed

–  errors

Sample JSON Response

§  GET /chatter/users/me: { currentStatus = ”chilling";

email = "[email protected]";

name = "Chris Seymour";

photo = { largePhotoUrl = "https://c.gus.content.soma.force.com/profilephoto/729B00000004FUd/F";

smallPhotoUrl = "https://c.gus.content.soma.force.com/profilephoto/729B00000004FUd/T";

};

title = "Senior Member of Technical Staff";

... }

Users Resource

§  Using /chatter/users/<id> and sub-resources: –  Getting user profile

–  Uploading a new photo –  Following records

–  Getting followers –  Retrieving group memberships

§  The alias “me” can be used in place of <id> to access information about the logged-in user

Getting a User Profile

§  GET https://na1.salesforce.com/services/data/v22.0/chatter/users/005D0000001KfqUIAS

§  Response includes Chatter user profile data

Following a Record

§  POST https://na1.salesforce.com/services/data/v22.0/chatter/users/me/following –  Content-Type: application/x-www-form-urlencoded –  Body or param: subjectId=005D0000001Khtv

§  Response includes a URL that can be DELETEd to remove the subscription

Groups Resource

§  Using /chatter/groups/<id>, and sub-resources: –  Getting group information

–  Getting/adding group members –  Getting/posting group photo

Getting Group Info

§  GET https://na1.salesforce.com/services/data/v22.0/chatter/groups/0F9D00000000Enl

§  Response includes Chatter group description and member count

Adding a Group Member

§  POST https://na1.salesforce.com/services/data/v22.0/chatter/groups/0F9D00000000Enl/members –  Content-Type: application/x-www-form-urlencoded –  Body: userId=005D0000001Khtv

Feeds

§  Feed resources provide the feed item data found in the Chatter web UI

§  Issue a GET for feed items using a URL like:

/chatter/feeds/<feed type>/feed-items §  Feed responses are paged

News Feed

§  /chatter/feeds/news/me

User Profile Feed

§  /chatter/feeds/user-profile/<user id>

Record Feed

§  /chatter/feeds/record/<id>

Feed Items

§  Feed item properties include: –  createdDate –  type: text post, user status, link post, file post, or tracked

change

–  actor: user or record that posted the feed item

–  comments: first page of comments –  likes: first page of likes

–  body: unformatted text and formatted message segments

Feed Item Body

§  The feed item “body” holds both formatted and unformatted body text properties: –  text: body as unformatted text –  message segments: body as a list of rich segments:

•  Text

•  Hashtag

•  Link

•  Mention (including user information)

Feed Item Body

Text Mention Text Hashtag Text

Common Feed Operations

§  Post a new feed item to a user profile: POST /chatter/feeds/user-profile/005x77839472/feed-items?text=this%20is%20my%20post%20text

§  Comment on a feed item: POST /chatter/feed-items/005x6659304892/comments?text=some%20exciting%20comment

§  Unlike a feed item: DELETE /chatter/likes/005x884930284

Example Code – iOS and Rails

iOS

Ruby

App Building Tips

§  Learn OAuth2 –  which “flow” is suitable for your application context?

–  how much trust are you putting in end-user devices?

§  Use separate remote access apps for production and development

Common Stumbling Points

§  Group feeds are just record feeds: /chatter/feeds/record/<group id>

§  A “user profile” feed is different from a “user record” feed

§  News feed can only be retrieved for the logged-in user

§  Following an object is described by a “subscription”. DELETE the subscription to stop following

Rate Limiting and Availability

§  Rate limiting: –  each user + remote access app combination gets 200 requests

per hour

§  The Chatter API is on in all organizations that have Chatter –  There is nothing the org needs to purchase, its default on.

§  All user types that support Chatter may use the API –  Portal users are not supported, since they don’t have chatter.

–  Users must have the “api enabled” user profile perm on.

§ The Chatter API makes your applications social § Easy to integrate with existing applications § Great for mobile too

Key Take Aways

How do I begin?

§ The Chatter API is available now in all organizations that have Chatter

See the resource page for documentation, sample apps, tips, and a video of this presentation

https://developer.force.com/chatter-api