README
node.js Facebook SDK
This is a complete port of Facebook's PHP SDK library.
The Facebook Platform is a set of APIs that make your application more social. Read more about integrating Facebook with your web site on the Facebook developer site.
The node.js Facebook SDK is licensed under the Apache License, Version 2.0, as was the original library.
Install
npm install facebook-nodejs-sdk
Use as connect middleware
The following will attach a new Facebook object to each incoming http request. For more information on querying Facebook's graph api, see developers.facebook.com.
var connect = require('connect'),
fbsdk = require('facebook-sdk');
connect()
.use(connect.cookieParser())
.use(connect.bodyParser())
.use(fbsdk.facebook({
appId : 'YOUR APP ID',
secret : 'YOUR API SECRET'
}))
.use(function(req, res, next) {
if (req.facebook.getSession()) {
res.end('<a href="' + req.facebook.getLogoutUrl() + '">Logout</a>');
// get my graph api information
req.facebook.api('/me', function(me) {
console.log(me);
});
} else {
res.end('<a href="' + req.facebook.getLoginUrl() + '">Login</a>');
}
})
.listen(3000);