Created
June 9, 2014 04:40
-
-
Save aroman/b0aa26b758942851da6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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