Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-06-2013, 02:42 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
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


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.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.
__________________
Reply With Quote
  #2  
Old 07-06-2013, 05:13 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Here's some fancy graph to show what actually happened...



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.
__________________
Reply With Quote
  #3  
Old 07-08-2013, 09:15 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
I love it will talk to Novo about using it on Delteria!
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:44 PM.


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