npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

facebook-client-bn

v1.6.1-2

Published

A fork of the original facebook-client. A javascript (nodejs) implementation of facebook's client for oauth and rest+graph api.

Downloads

5

Readme

node-facebook-client README

Version: 1.5.0

This version is forked from dracoblue, and contains some timeout fixes. npm package is called facebook-client-bn

Official Site: http://dracoblue.net/

node-facebook-client is copyright 2010-2011 by DracoBlue http://dracoblue.net

What is node-facebook-client?

The node-facebook-client library is a set of nodejs classes to communicate with the rest and graph api provided by facebook.

It works great if you embed the facebook connect button on your page and want to use the rest + graph api by facebook. Oauth-support may work but is not tested that well.

The library is not officially created nor maintained by facebook. It is created by dracoblue and licensed under the terms of MIT License.

Example

This small example uses the FacebookClient class to retrieve the name of a user. requst.headers are the headers from the server request.

var FacebookClient = require("facebook-client").FacebookClient;

var facebook_client = new FacebookClient(
    "yourappid", // configure like your fb app page states
    "yourappsecret" // configure like your fb app page states
);

facebook_client.getSessionByRequestHeaders(request.headers)(function(facebook_session) {
    facebook_session.graphCall("/me", {
    })(function(result) {
        console.log('Username is:' + result.name);
    });
    facebook_session.graphCall("/me/feed", {message:"I love node.js!"}, 'POST')(function(result) {
        console.log('The new feed post id is: ' + result.id);
    });
});

A full example may be executed with: node run_example.js. Please configure yourappid+yourappsecret in that file first.

Graph API

FacebookClient#graphCall(path, params[, method])

Doing a call against the graph server.

client.graphCall(path, params, method)(function(result) {
    // 
});

The parameter method can be omitted and is 'GET' in this case.

Rest API

FacebookSession#restCall(method, params, access_token)

Doing a signed call against the rest api server, by using the session of the user.

session.restCall("users.getInfo", {
    fields: "name",
    uids: session.uid
})(function(response_users) {
    // work with it
});

General API

FacebookClient#getSessionByRequestHeaders(request_headers)

Use the request headers to retrieve the session.

facebook_client.getSessionByRequestHeaders(request.headers)(function(facebook_session) {
    // session is either undefined or a valid FacebookSession
});

FacebookSession#isValid()

Calls /me on the graph api, to check whether the session is still valid or the user has already logged out.

session.isValid()(function(is_valid) {
    // is either true or false
});

Remember to do that only when necessary and not on every request.

FacebookClient#getSessionByAccessToken(access_token)

Creating a new FacebookSession instance with a given access_token.

FacebookSession#getId()

Retrieving the id of the session.

session.getId()(function(id) {
    // is either a string or undefined, in case the session has no id
});

FacebookSession#getMeta()

Tries to retrieve all data from the graph call /me for the user. This is only available in case of a session, which got initialized by an access_token.

session.getMeta()(function(user_data) {
    // work with it
});

Internal API

FacebookClient#getAccessToken(access_params)

Retrieving an AccessToken with the given parameters. You don't need to use this function if you used FacebookClient#getSessionByRequestHeaders.

client.getAccessToken(access_params)(function(access_token, expires) {
    // 
});

FacebookSession#retrieveAccessToken(code, redirect_uri)

Retrieve an access token by providing a code and a redirect_uri. Usually from successful oauth redirect.

FacebookSession#injectAccessToken(access_token)

Used to inject an access_token into an existing FacebookSession. This will enable calls like FacebookSession#restCall and FacebookSession#graphCall to work authenticated. It is triggered by FacebookClient#getSessionByRequestHeaders after successful creation of the session.

FacebookSession#getAccessToken(access_params)

Retrieving an AccessToken with the given parameters and injecting it into the FacebookSession.

FacebookToolkit.generateSignature(params, api_secret)

Calculates the signature for a given set of parameters and the api_secret.

Changelog

  • 1.4.0 (2011/10/06)
    • added multiquery-support. #12
  • 1.3.0 (2011/04/26)
    • added FacebookSession#isValid
    • fixed expires validation fixes #5
    • added method argument to session.graphCall to permit POSTing in addition to GETting
  • 1.2.0 (2011/03/09)
    • added support for node 0.4
  • 1.1.0 (2010/12/29)
    • removed session_key support
    • added example
  • 1.0.1 (2010/12/29)
    • added secure url for access_token
  • 1.0.0 (2010/10/05)
    • Initial release

Contributors

  • DracoBlue http://dracoblue.net
  • jharlap https://github.com/jharlap

License

node-facebook-client is licensed under the terms of MIT. See LICENSE for more information.