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

@digitalideastudio/node-facebook-api

v1.0.18

Published

Nodejs module for performing facebook graph api calls

Downloads

32

Readme

Facebook Client for Node

Installation

npm install @digitalideastudio/node-facebook-api

Usage

Step 1. Initialization

import NodeFacebook from '@digitalideastudio/node-facebook-api';

const fb = new NodeFacebook();

Step 2. User Consent

const url = await fb.getOAuthUrl();

console.log(url); // Send to the frontend so user can see FB OAuth2 Consent window and retrieve a code

OAuth Consent Window

Step 3. Exchange the code to Access Token

fb.authenticate(code); // specify the code sent by frontend once user authenticated in FB OAuth2 Consent window

Ready to use Facebook API

Now you can use any API calls the same you can use on API Explorer:

fb.get('me');
fb.get('me/videos');
fb.get('me/posts');
fb.get('me', { fields: 'first_name,last_name,email' });

Support of env vars

As mentioned above, to instantiate NodeFacebook class you can do the following:

const fb = new NodeFacebook();

This will work when you have the following lines in your .env file (or process.env):

FACEBOOK_CLIENT_ID=XXXXXXXXXX
FACEBOOK_CLIENT_SECRET=XXX
FACEBOOK_SCOPE=email,user_birthday,user_location,public_profile,user_friends
FACEBOOK_REDIRECT_URI=http://localhost:4000

FACEBOOK_DEBUG=true # optional
FACEBOOK_VERSION=8.0 # optional
FACEBOOK_MOBILE=true # optional

Alternatively, you can pass these options directly to the constructor:

const fb = new NodeFacebook({
  client_id: 'XXXXXXX',
  client_secret: 'XXXXXXXXX',
  redirect_uri: 'http://localhost:4000',
  scope: 'email,user_birthday,user_location,public_profile,user_friends',

  // Optional
  mobile: true,
  version: '8.0',
  debug: true,
});