Hello,
On Era we do a lot of Facebook Events, which require the user to either like a status or share a page for a prize. Here's an example
So, instead of us going through each of these shares and selecting random users you can get the information via a script.
You will need to collect the postID from Facebook, here's how
Highlight over the date of the post, and the link at the bottom of your page will appear. Take the 'fbid' flag.
PHP Code:
function onCreated() {
//Facebook Post ID
temp.postID = "534261823300559";
//How many winners to select
temp.winners = 9;
//Catch the response
temp.json = new TStaticVar("GSyncResponse" @ int(timevar2 * 100));
temp.req = "http://graph.facebook.com/" @ temp.postID @ "/likes?limit=9999";
temp.response = this.get(temp.req);
//Add it to the object
temp.json.loadJSONFromString(temp.response);
//Do a loop through to find the winners
for (temp.i = 0; temp.i < temp.winners; temp.i++) {
//Select one at random
temp.rand = int(random(0, temp.json.data.size()));
//Return the data
temp.fb_ID = temp.json.data[temp.rand].id;
temp.fb_Name = temp.json.data[temp.rand].xmlname;
echo("Winner:" SPC temp.fb_Name SPC "http://www.facebook.com/" @ temp.fb_ID);
}
}
//Http Functions Class (Made by Chris Vimes)
function get(temp.url, temp.reqTimeout) {
temp.req = new TCURLRequest();
temp.req.url = temp.url;
return this.getDataFromRequest(temp.req, temp.reqTimeout);
}
// helper functions
function getDataFromRequest(temp.req, temp.reqTimeout) {
// default to 30 second timeout if none given
if (temp.reqTimeout <= 0) {
temp.reqTimeout = 30;
}
// send request and wait for data
temp.req.sendRequest();
waitfor(temp.req, "onReceiveData", temp.reqTimeout);
temp.data = temp.req.data;
temp.req.destroy();
return temp.data;
}
This is what it will return
HTML Code:
Winner: Ellie Graal http://www.facebook.com/1000
Winner: Bob Bob http://www.facebook.com/1
Winner: KM http://www.facebook.com/10000
Winner: HD http://www.facebook.com/10000508
etc
Which you can contact the winners to award their prize.