Chapter 9. Facebook API

You’ve done a bang-up job of planning, your brilliant, unpolished diamond is starting to shine with a beautiful design, you have stellar FBML built out on a standards-compliant framework, your FBJS screams Ajax cleanliness from 1,000 feet away, and you’ve mastered FQL queries like the back of your normalized (and partially denormalized) hand. Now what?

Time to dig into the Facebook Application Programming Interface (API). If you’re unfamiliar with the concept of an API, read the first few recipes in this chapter carefully. The majority of the content here will cover the various API calls and how to get different types of data in and out of Facebook, with some extra attention at the end to some of the new beta features that have recently been introduced. As with the rest of this book, I’m going to cover the API using the official Facebook PHP Client, but it shouldn’t be too hard to convert these examples into your language of choice.

Note

In the interest of saving space (and trees!), I’ve omitted the code to set up a Facebook Client object and retrieve the active user from most of the recipes in this chapter. Since it’s always the same, refer to What’s an API? for reference.

You should be able to look up any of the API calls covered in this chapter by adding them to the end of the Facebook Developers Wiki URL. As an example, if you want more info on Users.getInfo(), go to http://wiki.developers.facebook.com/index.php/Users.getInfo.

What’s an API?

Problem

I keep hearing ...

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.