Skip to content

Instantly share code, notes, and snippets.

@stevedev
Created July 21, 2011 15:25
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save stevedev/1097432 to your computer and use it in GitHub Desktop.
Save stevedev/1097432 to your computer and use it in GitHub Desktop.
Facebook Cheatsheet

Facebook Cheatsheet

Graph API

The Graph API is Facebook's RESTful API for interacting with data from User's, Application's and Company's "social graph" or information. Some calls require authorization and some do not.

Reference: http://developers.facebook.com/docs/reference/api/

Explorer tool: http://developers.facebook.com/tools/explorer/?method=GET&path=621042512

Public Information

Public information is available without authorization. Basic information about a user, for example: https://graph.facebook.com/steve.thompson You can get quite a bit more information from a page, versus a user:

Private Information

There are basically two ways to get authorization and how you use them depend on what information you are requesting:

  1. If you are making an app for a Page, that only needs access to that Page's information, you just need the appId and secret.
  2. To access a user's page you have to first get their permission using oAuth. PHP's SDK makes that pretty simple. This is what you need to do to post to their wall, access their photos, get a list of their friends, update their status, etc.

Real time updates

If you store user information on your site, or you want to have your site/app react when something changes on one of your users' accounts, you can use the Real-time Updates. Basically, you subscribe to what you want sent to you, setup a callback handling script, and then figure out what you want to do with it on your site/app.

http://developers.facebook.com/docs/reference/api/realtime/

PHP SDK

To push data back to facebook (if you have the correct permissions from the user):

$data = array(
  'message' => 'Postin to my wall'
);

$facebook->api('/steve.thompson/feed', 'post', $data);

FQL

You can use FQL to do more efficient and advanced queries, as well as gain access to information that you cannot get through the Graph API.

Here is a great slideshow on FQL: http://www.slideshare.net/csaila/fql-overview

http://developers.facebook.com/docs/reference/fql/

Dialogs

Dialogs let you use Facebook to post to walls on your site, without any programming. For example, you could pop open a window and direct it to http://www.facebook.com/dialog/feed?app_id=123050457758183&redirect_uri=http://www.example.com/response/&display=popup and then you'd have an instant Post to My Wall Dialog.

View more here: http://developers.facebook.com/docs/reference/dialogs/

Social Channels

These are just Javascript SDK based methods that you can use to publish content back to Facebook. Includes a post to my wall dialog, an invite your friends dialog, a like button.

http://developers.facebook.com/docs/channels/

Opengraph

These are meta tags that you can embed in the of your html that explicitly provide information about the page content to Facebook. You'd use these, for example, if you had a page about a photo and you wanted to provide a thumbnail to Facebook and a description.

You can view how Facebook analyzes a page by going here: http://developers.facebook.com/tools/lint/

Javascript SDK

I personally despise this SDK and have found it very frustrating to use in combination with the PHP-SDK. Either use one or the other.

Using Facebook for Authentication on your site

http://developers.facebook.com/docs/guides/web/#login

Other links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment