Skip to content

Instantly share code, notes, and snippets.

@elf-pavlik
Last active January 2, 2016 03:09
Show Gist options
  • Save elf-pavlik/8242165 to your computer and use it in GitHub Desktop.
Save elf-pavlik/8242165 to your computer and use it in GitHub Desktop.
var fb = require('fbgraph');
var IDS = {
ouishareGlobal: 226111377405815
};
fb.setAccessToken(process.env.FACEBOOK);
function byComments (first, second) {
return first.comments.data.length - second.comments.data.length;
}
function hasComments (post) {
return post.comments && post.comments.data.length >= 10;
}
fb.get(IDS.ouishareGlobal + '/feed', { limit: 1000 }, function(err, res){
if ( err ) {
console.log(err);
}
var posts = res.data;
console.log(posts.length);
posts = posts.filter(hasComments);
posts = posts.sort(byComments);
posts = posts.reverse();
posts.forEach(function(post){
var stats = '* ' + post.comments.data.length + ' - ' + post.actions[0].link;
console.log(stats);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment