victorianrider Posted May 17, 2011 Share Posted May 17, 2011 Hi, I've been semi-teaching myself curl, and I decided to try logging into Facebook with it. This is what I have so far... <?PHP $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? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/236612-curl-help-with-logging-in/ Share on other sites More sharing options...
anupamsaha Posted May 17, 2011 Share Posted May 17, 2011 Please check "cookiejar" for cURL http://curl.haxx.se/libcurl/php/examples/cookiejar.html. It might help you. Quote Link to comment https://forums.phpfreaks.com/topic/236612-curl-help-with-logging-in/#findComment-1216386 Share on other sites More sharing options...
victorianrider Posted May 17, 2011 Author Share Posted May 17, 2011 Please check "cookiejar" for cURL http://curl.haxx.se/libcurl/php/examples/cookiejar.html. It might help you. Thank you very much Worked a treat. I'll bookmark this site, has a lot of resourceful information on it regarding curl. I've searched google for tutorials and haven't had much luck. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/236612-curl-help-with-logging-in/#findComment-1216391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.