30.03.2014 Views

Database.com Chatter REST API Developer's Guide - Salesforce.com

Database.com Chatter REST API Developer's Guide - Salesforce.com

Database.com Chatter REST API Developer's Guide - Salesforce.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introducing <strong>Chatter</strong> <strong>REST</strong> <strong>API</strong><br />

Send HTTP Requests with cURL<br />

Send HTTP Requests with cURL<br />

<strong>Chatter</strong> <strong>API</strong> uses HTTP methods to send and receive JSON and XML content, so it is very simple to build client applications<br />

using the tool or the language of your choice. We re<strong>com</strong>mend a <strong>com</strong>mand-line tool called cURL to simplify sending and<br />

receiving HTTP requests and responses.<br />

cURL is pre-installed on many Linux and Mac systems. Windows users can download a version at curl.haxx.se/. When<br />

using HTTPS on Windows, ensure that your system meets the cURL requirements for SSL.<br />

Your HTTP requests to a <strong>Chatter</strong> <strong>API</strong> resource should contain the following information:<br />

• An HTTP method (such as HEAD, GET, POST, or DELETE).<br />

• An OAuth 2.0 access token used to authenticate the request. For information on how to retrieve the token, see Step One:<br />

Set Up Authorization on page 25.<br />

• The <strong>Chatter</strong> <strong>API</strong> resource URL.<br />

• Any JSON or XML files containing information needed for requests, such as updating a record with new information.<br />

The HTTP methods are used to indicate the desired action, such as retrieving information, as well as creating, updating, and<br />

deleting records.<br />

• GET is used to retrieve information, such as basic resource summary information.<br />

• POST is used to create a new <strong>Chatter</strong> <strong>API</strong> item, such as a <strong>com</strong>ment or like, or subscribe to a group.<br />

• PATCH is used for partial updates to an item, for example, renaming a file.<br />

• PUT is used for whole updates to an item, for example, marking a conversation as read.<br />

• DELETE is used to delete a <strong>Chatter</strong> <strong>API</strong> item, such as a feed-item, or unsubscribe from a group.<br />

• HEAD is used to retrieve resource metadata. It's similar to using GET but without the response body. You can use HEAD<br />

for testing the availability of a resource.<br />

To access a resource, submit an HTTP request containing a header, method, and resource URL.<br />

Understanding OAuth and <strong>Chatter</strong> <strong>API</strong><br />

OAuth is an open protocol that allows secure authentication for access to a user's data, without handing out the user's username<br />

and password. It is often described as the valet key of software access: a valet key only allows access to certain features of your<br />

car: for example, you can’t open the trunk or glove <strong>com</strong>partment using a valet key.<br />

<strong>Chatter</strong> <strong>API</strong> uses OAuth to securely identify your application before connecting to <strong>Database</strong>.<strong>com</strong>.<br />

When you use OAuth, you can avoid storing login credentials in your application. Instead, your application can prompt the<br />

user to login using a standard <strong>Database</strong>.<strong>com</strong> page, which returns an access token to your application. Your application can use<br />

this access token to access <strong>Chatter</strong> <strong>API</strong> Web services. This approach to authentication can be used in both mobile apps and<br />

from a Web page.<br />

<strong>Chatter</strong> <strong>API</strong> uses OAuth 2.0..<br />

Understanding Connected Apps<br />

To use <strong>Chatter</strong> <strong>API</strong>, you must create a <strong>REST</strong> entry point in your organization. <strong>Database</strong>.<strong>com</strong> defines this entry point as a<br />

Connected App definition.<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!