Skip to content

Instantly share code, notes, and snippets.

@aroman
Created June 9, 2014 04:40
Show Gist options
  • Save aroman/b0aa26b758942851da6e to your computer and use it in GitHub Desktop.
Save aroman/b0aa26b758942851da6e to your computer and use it in GitHub Desktop.
// usage: node demo.js OR node demo.js <number>
var graph = require('fbgraph')
graph.setAccessToken('<get one here https://developers.facebook.com/tools/explorer>');
graph.setGraphVersion('2.0');
function explode (err) {
console.error(err);
process.exit(1);
};
function processPosts (url, callback, total) {
console.log(url);
total = total || 0;
graph.get(url, function (err, res) {
if (err) explode(err);
if (res.data.length === 0) return callback(total);
processPosts(res.paging.next, callback, total + res.data.length);
});
}
var limit = process.argv[2] || 25;
processPosts('163844093817909/feed?fields=created_time&limit=' + limit, function (total) {
console.log("Total was " + total);
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment