Accessing an Object's Connections with Introspection

Connections are the relationships between the objects in Graph API. You can find out what connections are available to each of your objects through a process called introspection.

Example connections include

  • Friends
  • Photos the user has uploaded
  • The user's news feed
  • Events a user is attending
  • Groups a user is in
  • Pages a user has liked
  • Videos a user has uploaded
  • Notes a user has written
  • Books a user likes
  • Music a user likes
  • Places a user has checked in to

image Objects by themselves are boring. What makes Facebook powerful and useful to you as a developer and marketer is the relationship among those objects. Facebook calls this the social graph. It's all the different ways that people connect with each other and share with each other, and you have access to all that, with the user's permission.

You can of course access connections if you already know what they are, but it's good practice to get the list of connections that are available for your objects. This keeps you from having to have a photographic memory and also protects you if Facebook ever changes its API.

A typical process of accessing an object's connections is as follows:

  1. Introspecting the connections of an object through the metadata=1 property to get the desired connection and the URL to call
  2. Authorizing the user, if necessary
  3. Calling the Graph API URL for the connection ...

Get Facebook® Application Development For Dummies® 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.