Last active
August 29, 2015 14:04
-
-
Save bilalsavas/cecc769cdb5b49ead307 to your computer and use it in GitHub Desktop.
extracts pdf catalogue of event attendees(picture,name) from facebook with graph api
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
import processing.pdf.*; | |
JSONObject json; | |
PImage img; | |
JSONArray j; | |
PFont font; | |
int yatay=0; | |
int dikey=0; | |
String access_token="fb access_token buraya"; | |
String event_id="701117369972203"; // startup istanbul meeting event_id | |
void setup() | |
{ | |
background(#efefef); | |
font = createFont("GothamRounded-Bold", 62); // createFont instead of loadFont, you dont have to import .vlw files | |
textFont(font); | |
size(800, 400, PDF, "attendees14.pdf"); | |
json = loadJSONObject("https://graph.facebook.com/" + event_id + "/attending?fields=picture.height(200).width(200),name&access_token=" + access_token); | |
j = json.getJSONArray("data"); | |
textSize(62); | |
textLeading(58); | |
rectMode(CORNER); | |
fill(0); | |
} | |
void draw() | |
{ | |
background(255); | |
line(0,0,400,400); | |
if(frameCount<j.size()) | |
{ | |
JSONObject item = j.getJSONObject(frameCount); | |
JSONObject picture = item.getJSONObject("picture"); | |
JSONObject data = picture.getJSONObject("data"); | |
String profilePic = data.getString("url"); | |
String name = item.getString("name").toUpperCase().replaceAll(" ","\n"); | |
rect(99,99,202,202); | |
img = loadImage(profilePic); | |
image(img, 100, 100, 200, 200); | |
text(name, 320, 160); | |
if(frameCount+1<j.size()){ | |
PGraphicsPDF pdf = (PGraphicsPDF) g; | |
pdf.nextPage(); | |
} | |
}else | |
{ | |
exit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment