Go to page and login with Curl

Asked

Viewed 1,249 times

0

I’m trying to log in with Curl on web pages using the simplest code possible but it never works even though the code being apparently correct follows the code:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://m.facebook.com/login.php');
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, '[email protected]&pass=senha123');
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec ($ch);
echo = $store;

1 answer

1


It doesn’t work because Facebook requires you to send more information. Simply monitoring the network traffic you can see that the "Login" is done in:

https://m.facebook.com/login/async/

It also sends a lot of data and not simply "email" and "password":

m_ts: 
li: 
try_number:
unrecognized_tries:
email: 
pass:
m_sess:
fb_dtsg:
lsd:
__dyn:
__req:
__ajax__:
__user:

If you disable Javascript it will use https://m.facebook.com/login.php, the same pointed by your URL, but containing in the body the information:

lsd:
m_ts:
li:
try_number:
unrecognized_tries:
email:
pass:
login:
_fb_noscript:

So you need to figure out how they are generated what they mean and then play this in Curl, so you can log in.

If you keep sending only email and pass you will never be able to access, at least it would not be logical for Facebook to allow this, maybe some information may not be sent, but this will have to be tested one by one.

Remember that Facebook has an API using Oauth, which is much safer than using login/password.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.