Socket
Book a DemoInstallSign in
Socket

facebook-graph

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

facebook-graph

Facebook Node.js SDK

0.0.6
latest
npmnpm
Version published
Weekly downloads
2
-83.33%
Maintainers
0
Weekly downloads
 
Created
Source

Facebook Node.js SDK

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 ? 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 ? 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.

Keywords

facebook

FAQs

Package last updated on 04 Apr 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.