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
https://forums.phpfreaks.com/topic/127105-solved-curl-into-facebook/
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);

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.