node package manager


Open graph actions made easier


Ridiculously simple facebook open graph caller.


npm install facebook-open-graph


var OpenGraph = require('facebook-open-graph'),
    openGraph = new OpenGraph('fb_app_namespace')

After that:

show actions:'some-user-id','some-access-token','action',function(err,response){
  // do stuff

publish action:

// enable fb:explicitly_shared
var options = true;

// ... or pass your own custom headers
options = {
  'fb:explicitly_shared': true

// the options parameter may be omitted if you have nothing to put in there
  // do stuff

delete action:

  // do stuff

In all of the above, err is a native javascript error or null, and response is a native javascript object (parsed response from FB).

You can use 'me' instead of a user, and provide their access token to publish to their own feed. Otherwise, provide an id, and either the users' access token or an app access token with the correct permissions.

** Common Actions **

Some facebook actions are "common", in that you'll need to use them instead of custom actions. These mostly are pretty specific, but this library currently supports the main two common actions:

** Like **

  // stuff

** Follow **


The main difference for common actions is that they are not namespaced - these actions will be transformed to og.likes and og.follows, and instead of specifying an object name, the name is ignored and the url is sent instead. Through this library, usage can be identical to your custom actions, so that should make things easier.

Sending explicitly_shared indicates that a user has explicitly chosen to have their action posted to their Facebook wall, giving it a more prominent position.

For more on this, see How-To: Explicit Sharing

Don't like using the word "publish" or whatever? Do what you want, homie:


Now you can:

  // whatever
  // yeah, killed the fucker