facebook-sdk

0.3.3 • Public • Published

** This library is unmaintained. Consider using Facebook's client-side JS library or a more recent client side library. **

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-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);

Stand alone usage

var fbsdk = require('facebook-sdk');

var facebook = new fbsdk.Facebook({
  appId  : 'YOUR APP ID',
  secret : 'YOUR API SECRET'
});

facebook.api('/YOUR APP ID', function(data) {
  console.log(data);
});

Tests

The tests have been ported to run using nodeunit. This was the easiest way to confirm the new node.js library works as expected. Some new tests have been added to cover edge cases, and others not relevant in the new environment have been removed.

Package Sidebar

Install

npm i facebook-sdk

Weekly Downloads

249

Version

0.3.3

License

none

Unpacked Size

55.9 kB

Total Files

10

Last publish

Collaborators

  • tenorviol