Jump to content

Curl help with Facebook


victorianrider

Recommended Posts

Hey guys,

 

Been trying to get my head around curl over the past month, I need help with loading one of Facebook's Applications.

 

I need the script to:

1) Log into Facebook.

2) Load up the application.

3) Load up the application's iFrame.

 

I've got steps 1 + 2 down, so it logs into Facebook and loads up the application alright, but when it comes to loading up the specific application's iframe, it re-directs me to log in again. I am 99% sure it's something to do with cookies because if you log in locally and load up the iframe url it has no problem loading up the app.

 

(Iframe URL: http://mobsters-fb-apache-dynamic-lb.playdom.com/prod_facebook/facebook/mobsters_v1/facebook_iframe.php?track=bookmark)

 

 

Here is my current code: (Running it in apache)

And also I am really new to curl and am pretty much learning on the go so please excuse any obvious errors :)

 

$Email = strip_tags(str_replace(' ', '', $_POST['email']));
$Password = strip_tags(str_replace(' ', '', $_POST['password']));
$MobstersURL = "http://apps.facebook.com/mobstersapp/index.php?track=bookmark&ref=bookmarks&count=0";
$FBlogin = 'https://www.facebook.com/login.php?login_attempt=1';
$Data = 'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=vuCfh&locale=en_US&email='.urlencode($Email).'&pass='.urlencode($Password).'&default_persistent=0&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&lsd=vuCfh';

$Cookie = "cookie.txt";

$fp = fopen($Cookie,'wb');   

   
$agent = "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7";
//login to facebook
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$FBlogin);   
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $Cookie);
curl_setopt($ch, CURLOPT_REFERER, $FBlogin);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POSTFIELDS, $Data);
       
$Excecute = curl_exec($ch);
//echo $Excecute;

//load up mobsters then display it

curl_setopt($ch, CURLOPT_URL,$MobstersURL);
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/?ref=logo");
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

$LoadMobsters = curl_exec($ch);
echo $LoadMobsters;











//load up mobsters in iframe THIS IS WHERE I'M STUCK

curl_setopt($ch, CURLOPT_URL, "http://mobsters-fb-apache-dynamic-lb.playdom.com/prod_facebook/facebook/mobsters_v1/facebook_iframe.php?track=bookmark");
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
curl_setopt($ch, CURLOPT_COOKIEFILE, $Cookie);
curl_setopt($ch, CURLOPT_REFERER, "http://apps.facebook.com/mobstersapp/index.php?track=bookmark&ref=bookmarks&count=0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);

$Load_iFrame = curl_exec($ch);

echo $Load_iFrame; // This is where I noticed it wasn't working since instead of loading up the iframe, it brought me back to facebook to log in.

 

So yeah I need some help in loading up the iframe since that is where I need to grab important data.

 

Any help would be much appreciated, and yes, I've been to http://php.net/manual/en/book.curl.php a billion times which is why I've come here where the pro's are for help ;)

 

Thanks.

Link to comment
Share on other sites

Your stealing a game thats meant to run within the walls of facebook.

 

I am not stealing it, the app can be run off-site so to speak, I'm simply trying to do it without logging in manually.

 

If you have the application installed, and you are logged into facebook and load up the iframe url the app will load with no problem, so I don't know why this would be defined as doing anything wrong.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.