Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Gathering Facebook Posts Data (https://forums.graalonline.com/forums/showthread.php?t=134268425)

xAndrewx 07-06-2013 02:42 PM

Gathering Facebook Posts Data
 
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
https://fbcdn-sphotos-e-a.akamaihd.n...96630503_n.png

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
http://puu.sh/3wnxw.jpg
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.0temp.temp.winnerstemp.i++) {
      
//Select one at random
    
temp.rand int(random(0temp.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.urltemp.reqTimeout) {
  
temp.req = new TCURLRequest();
  
temp.req.url temp.url;
 
  return 
this.getDataFromRequest(temp.reqtemp.reqTimeout);
}
 
// helper functions
function getDataFromRequest(temp.reqtemp.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.

xAndrewx 07-06-2013 05:13 PM

Here's some fancy graph to show what actually happened...

http://puu.sh/3ws9s.png

From the Facebook Share event- 22,000 saw the post. In this event, only 9 of the 22,000 people that saw the post won a prize. Pretty good publicity for free.

MysticalDragon 07-08-2013 09:15 PM

I love it will talk to Novo about using it on Delteria!


All times are GMT +2. The time now is 07:59 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.