Skip to content

Instantly share code, notes, and snippets.

@Hydrotoast
Last active December 10, 2015 15:18
Show Gist options
  • Save Hydrotoast/4452860 to your computer and use it in GitHub Desktop.
Save Hydrotoast/4452860 to your computer and use it in GitHub Desktop.
function GroupMining() {
this.member_ids = [];
this.semaphore = 0;
this.groupsCount = 1;
}
GroupMining.prototype = {
unlock: function() {
if (++(this.semaphore) === this.groupsCount) {
resultStr = this.member_ids.join(',');
console.log(resultStr);
}
return this.semaphore;
}
};
FB.getLoginStatus(function(response) {
gm = new GroupMining();
if (response.status != 'connected')
return;
// ACM's Group ID is 228954137162541
// Repeat this call for every group whose members you wish to mine
FB.api('/228954137162541/members', function(result) {
for (var i = 0; i < result.data.length; i++)
gm.member_ids.push(result.data[i].id);
gm.unlock();
});
});
@Hydrotoast
Copy link
Author

Needs a set data structure to prevent duplicate IDs from reappearing in multiple group queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment