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.
This module have function same you use browser.
-
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'))});
kiat-bot is sample use node-facebook
node-facebook
has been inspired by facebook-chat-api
Thanks to Avery Morin for excellent prior art !
Thanks goes to these wonderful people (emoji key):
Hongarc 📆 👀 | Avery Morin 🤔 | Oliver Cristian 📢 |
This project follows the all-contributors specification. Contributions of any kind welcome!