Commit 1d33ed5c authored by Killian Kemps's avatar Killian Kemps

Add basic facebook chat connection

parents
const fs = require('fs');
var login = require("facebook-chat-api");
fs.exists('appstate.json', function(exists) {
if (exists) {
console.log('Login from saved appstate');
login({appState: JSON.parse(fs.readFileSync('appstate.json', 'utf8'))}, function callback (err, api) {
if(err) return console.error(err);
// Here you can use the api
});
}
else {
console.log('Login from user credentials');
login({email: "FB_EMAIL", password: "FB_PASSWORD"}, function callback (err, api) {
if(err) return console.error(err);
fs.writeFileSync('appstate.json', JSON.stringify(api.getAppState()));
});
}
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment