Skip to content

Instantly share code, notes, and snippets.

@rachtsingh
Created January 26, 2014 20:26
Show Gist options
  • Save rachtsingh/8639019 to your computer and use it in GitHub Desktop.
Save rachtsingh/8639019 to your computer and use it in GitHub Desktop.
A script to download the 20 facts information about the Harvard Class of 2018 and encrypt the resulting JSON. Obviously some information deleted for privacy
function executeScript(){
var no = {}; // list of excluded users
re = new RegExp("[4][\:|\.|\)|\-][^1-9]");
function findmatches(response){
flag = true;
if (response.data.length < 2){ // empty response, sort of
flag = false;
}
if(flag){
response.data.forEach(function(post){
if (post.message && (post.message.match(re) != null) && !(post.from.name in no) ){
posts.push(post);
}
});
FB.api(response.paging.next, findmatches);
}
else {
getPictures(); // get profile pictures for people
}
}
FB.api('/#/feed/', findmatches); // where # is the group id, sorry
}
function getPictures(){
counts = posts.length;
posts.forEach(function(post){
FB.api("/" + post.from.id + "/?fields=picture.type(square)", function(response){
post.picture = response.picture.data.url;
delete post.likes; // gotta keep the data size at least a little reasonable
delete post.comments;
delete post.actions;
delete post.application;
delete post.privacy;
delete post.type;
delete post.updated_time;
counts -= 1;
if (counts == 0){
saveOutput();
}
});
});
}
function saveOutput(){
encrypted = CryptoJS.AES.encrypt(JSON.stringify(posts), '' /* KEY HERE */);
var blob = new Blob([encrypted], {type: "text/plain;charset=utf-8"});
saveAs(blob, "harvard.dat");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment