Jump to content

[SOLVED] curl into facebook


quasiman

Recommended Posts

I'm using a curl script to login to my facebook account, and now that they're switching to the "new" look, I had to change the url in my curl.  It still works fine, but only for my account.  If I login to a brand new facebook account, the "new" portion in the url isn't there.

 

IE:

http://www.facebook.com/home.php?ref=home

 

and

 

http://www.new.facebook.com/home.php?ref=home

 

So my question, how do I make the curl script know which version I'm logging into?

 

My login script:

		$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://login.facebook.com/login.php?m&next=http%3A%2F%2Fm.facebook.com%2Fhome.php');
	curl_setopt($ch, CURLOPT_POSTFIELDS,'email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&login=Login');
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_COOKIEJAR, $face_cookie);
	curl_setopt($ch, CURLOPT_COOKIEFILE, $face_cookie);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
	curl_exec($ch);

Link to comment
Share on other sites

the login itself is fine, but once logged in the user (or curl script) is redirected to either of the above addresses...depending on when their account was created.  My older facebook account has the "new", while my account created yesterday does not.

you're right, it should be

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);

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.