Last active
January 2, 2016 03:09
-
-
Save elf-pavlik/8242165 to your computer and use it in GitHub Desktop.
This file contains 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
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