A package that wraps the Facebook javascript api to provide promises rather than callbacks.
Use the standard Facebook SDK on the browser and facebook-node-sdk
in node.js.
So far it works in the browser with the mr package loader from MontageJS.
The main module returns a function that accept the Facebook application id as an argument and returns a promise for the
FB object.
At the moment only api
, ui
, login
, logout
, and getLoginStatus
methods return promises.
See FB.api()
path
, method
, params
promise for the response's data
See FB.ui()
params
promise for the dialog's response data
See FB.login()
params
promise for the facebook object in a logged in state
See FB.logout()
none
promise for the facebook object in a logged out state
force
: Force reloading the login status (default false).
promise for the logout response
var facebook = require("./facebook")(<YOUR_APP_ID>);
facebook
.then(function (facebook) {
return facebook.login({scope: 'user_photos'});
})
.then(function () {
return facebook.api('/me/albums', 'get');
})
.then(function (albums) {
return facebook.api('/'+albums[0].id+'/photos', 'get');
})
.then(function (results) {
console.log("results", results);
})
.done();