Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
[DEPRECATED] Facebook Node.js SDK
Branch: develop
Pull request Compare This branch is even with gasi:develop.

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.npmignore
CHANGELOG.md
LICENSE
README.md
TODO.md
package.json

README.md

Facebook Node.js SDK

This SDK is deprecated.

This SDK is currently no longer supported since it’s a port of the Facebook Python SDK which has been deprecated. More…

This is a port of the official Facebook Python SDK to Node.js. Why did I choose the Python SDK? Because it's simple, clean and beautiful code. Besides, I only needed support for the Graph API.

This client library is designed to support the Facebook Graph API and the official Facebook JavaScript SDK, which is the canonical way to implement Facebook authentication. You can read more about the Graph API at http://developers.facebook.com/docs/api.

Installation

npm install facebook-graph

Development

git clone https://github.com/gasi/node-facebook-graph.git facebook-graph
npm link ./facebook-graph

Running Tests

node test

Basic usage

var facebook = require('facebook-graph');
var accessToken = '<Your OAuth Access Token>';
var graph = new facebook.GraphAPI(accessToken);

function print(error, data) {
    console.log(error || data);
}

graph.getObject('me', print);
graph.getConnections('me', 'friends', print);
graph.putObject('me', 'feed', {
    message: 'The computerz iz writing on my wallz!1'
}, print);

Express JS

If you are using the module within a web application with the JavaScript SDK, you can also use the module to use Facebook for login, parsing the cookie set by the JavaScript SDK for logged in users. For example, in in the Express web framework, you could get the profile of the logged in user with:

// This snippet assumes that you're using the
// connect.cookieParser (http://senchalabs.github.com/connect/middleware-cookieParser.html)
// middleware.
var facebook = require('facebook-graph');
var user = facebook.getUserFromCookie(req.cookies, appId, appSecret);
if (user) {
    var graph = new facebook.GraphAPI(user['access_token']);
    function print(error, data) {
        console.log(error || data);
    }
    graph.getObject('me', print);
    graph.getConnections('me', 'friends', print);
    graph.putObject('me', 'feed', {message: 'The computerz iz writing on my wallz!1'}, print);
}

Acknowledgements

Implementation and documentation ported from the official Facebook Python SDK and Facebook PHP SDK.

Thanks for supporting open source, Facebook.

Reporting Issues

Please file bugs or other issues in our issues tracker.

Something went wrong with that request. Please try again.