Skip to content

hong4rc/node-facebook

Repository files navigation

node-facebook

All Contributors

FOSSA Status shield NPM Version NPM Downloads License

Travis Codecov Code style CodeFactor

FOSSA Status large

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js.

Installation is done using npm or yarn:

$ npm install node-facebook
or
$ yarn add node-facebook

Follow node-facebook's wiki for more information.

Feature

This module have function same you use browser.

Usage

  • In first time, you should login with email and password:

  • When you logged in, use api.getState() to save cookie with this code:

const fs = require('fs');
const Facebook = require('node-facebook');

const me = new Facebook({email: 'your username/id', pass: 'your pass'});
me.login()
  .then((api) => {
    fs.writeFileSync('state.json', JSON.stringify(api.getState()));
  });
  • Now, you can login with cookie with file state.json:
const me = new Facebook({state: JSON.parse(fs.readFileSync('state.json', 'utf8'))});

Example

kiat-bot is sample use node-facebook

Credits

node-facebook has been inspired by facebook-chat-api Thanks to Avery Morin for excellent prior art !

Contributors

Thanks goes to these wonderful people (emoji key):

Hongarc
Hongarc

📆 👀 ⚠️ 💻
Avery Morin
Avery Morin

🤔
Oliver Cristian
Oliver Cristian

📢

This project follows the all-contributors specification. Contributions of any kind welcome!