Jump to content

Curl help with logging in.


Recommended Posts


I've been semi-teaching myself curl, and I decided to try logging into Facebook with it.

This is what I have so far...

$Email = strip_tags(str_replace(' ', '', $_POST['email']));
$Password = strip_tags(str_replace(' ', '', $_POST['password']));

$FBlogin = 'https://www.facebook.com/login.php?login_attempt=1';

$MoreData = "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=u2nsf&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=u2nsf";
$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, $MoreData);
$Excecute = curl_exec($ch);
echo $Excecute;


Right now I have it echo'ing out to see what's going wrong. I'm getting cookie errors from facebook saying that "I must have cookies enabled".

What could be wrong in my script that would trip such an error?




Link to comment
Share on other sites


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.