I’ve been playing with the Chatter REST API for a while now. If you haven’t checked out what the Chatter API is, you might want to start with a recent webinar we did covering Social Apps with Chatter and the Chatter API. Whenever I am working with the API, the part that takes the most amount of time is working with the JSON response. Good news is that once you become familiar with the structure, the rest(no pun intended) is pretty straightforward.

I’m going to be presenting at Cloudstock London in a few weeks (did you register already?). One of the things I am going to use heavily during the session is the Apigee Console. Apigee is a great tool for testing REST-based APIs, and it even has built in providers for both the Salesforce REST API, and the Chatter REST API.

Let’s look at an example of using the Apigee Console for newsfeeds. During my session at Cloudstock London I will be covering more examples as well as some tips and tricks to help you build efficient social apps. But for now, back to the console.

The Chatter news feed, like all the other Chatter API resources, is a REST resource. It looks like this: [your salesforce instance. eg: https://na1.salesforce.com/services/data/v24.0/]chatter/feeds/news/[userid or 'me'/feed-items. We are retrieving our our news feed so the 'me' keyword works perfectly. If you have a resource URL that requires inputs such as a feeditem id, the Apigee Console supports this through the Template tab, or if you are are using a resource that supports queries, you can use the Query tab.

Once I am logged in (choose OAuth2 from the Authentication dropdown), I can perform a GET against my resource and see a nicely formatted JSON response returned in the console. Once you have the response, you can start to become familar with the response payload and how you might work with it in your app. For example, the Rails snippet below is from a sample app I wrote a while ago using Rails, JQuery Mobile and the Chatter API, called Rhatter (A combination of Rails and Chatter). The snippet shows how you might retrieve and present the standard Chatter profile information  on a mobile app (notice how you handle the phone number pop...cool huh)

 

<div data-role="collapsible" data-collapsed="true" >
	<h3 >About Me</h3>
			<div><b>Name: </b> 	<%= @userInfo["name"] %></div>
			<div><b>Email: </b> <%= @userInfo["email"] %></div>
			<% @userInfo["phoneNumbers"].each do |ph| %>
			  	<div>
					<b>Phone <%= ph["type"]%>:</b>
					<!– tel protocol only works on an actual phone,
						 not the simulator –>
					<a href=’tel:<%= ph["number"] %>’
						rel=”external”><%= ph["number"] %></a>
				</div>
			<% end %>
			<div><b>Location: </b> <%= @userInfo["address"]["street"] %>,
								<%= @userInfo["address"]["city"] %>
			 					<%= @userInfo["address"]["state"] %></div>
			<div><b>About Me:</b><i><%= @userInfo["aboutMe"] %> </i></div>
</div>

 

If you are interested in learning some more tips and tricks on using the Chatter API, definitely come and check out the Chatter API session at Cloudstock London. Registration is filling up first. To make sure you don't miss out, sign up now. I hear we have some surprises for developers brewing (stay tuned for more info, but you don't want to miss out!) And thanks to Apigee for making a great developer tool!

 

tagged , , , Bookmark the permalink. Trackbacks are closed, but you can post a comment.
  • Anonymous

    I like Apigee, but I cannot login the SFDC with MyDomain-enalbed through Apigee.

    • http://twitter.com/quintonwall quintonwall

      Do you receive an error, or just could not find the oauth authentication option? The UI is a little confusing to start with

      • Anonymous

        Thanks for reply. I test it again. And it is OK for developer org. with my domain. But it just cannot login for sandbox with my domain. No error info. just can’t login in the Apigee. I guess something wrong with the callback link after I logined to the SFDC.