Accessing Data in Objects

Accessing the data in an object can be as simple as just pulling it up in a browser window, or writing some JavaScript or PHP or other language that calls the object by making a GET request from your server or the browser client. Almost every language has some sort of Facebook library to allow this, so Google it, or look up what libraries are available for your language of choice.

As a worst-case scenario, making Graph API calls is as simple as knowing how to make a GET request from your preferred programming language, so even if it doesn't have methods for making Graph API calls, it should be trivial for most programmers to write their own. In the following sections, I show you how you can access a simple object's information in code using the standard languages JavaScript and PHP.

Accessing an object's information using JavaScript

In Chapter 7, I show you basic ways that you can integrate Facebook APIs on your Web site using JavaScript. In this section, I assume that you've already included the Facebook library <script> tags and that you've already called your init block with your app ID in it. Assuming that's the case, you just need to call the FB.api method to get your object. If not, I suggest you read Chapter 7, where I provide some samples you can use.

The FB.api call takes, at a minimum, the Graph API path followed by a list of parameters that you can use to get more specific in your object call. The basic parameters that FB.api takes are as follows: ...

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.