RESTing with Facebook

Problem

I’m curious to know more about how my app communicates with Facebook. What kind of API is this?

Solution

This is a Representational State Transfer, or REST-like API, which means that calls are simply made over HTTP (using GET or POST) to the Facebook server. You’ll be POSTing requests to http://api.facebook.com/restserver.php when you make calls from your server, but you can visit that URL directly if you’re curious to see what a 101 error response looks like (and who isn’t, really?).

Discussion

The alternative to REST is generally considered to be SOAP, a heavier-weight protocol that includes an additional message layer. The two are very similar in some regards (both generally use HTTP as their transport protocol and generally use XML to encode data), but there’s a lot more overhead in implementing a SOAP-based API. More information about REST and SOAP can be found at http://en.wikipedia.org/wiki/Representational_State_Transfer and http://en.wikipedia.org/wiki/SOAP, respectively.

Get Facebook Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.