Go to the page and log in with Curl

0

I'm trying to login with Curl on web pages using the simplest code possible but never works even the code being seemingly 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;
    
asked by anonymous 13.06.2017 / 07:13

1 answer

1

It does not work because Facebook requires you to submit more information. By 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, you will use https://m.facebook.com/login.php , the same as your cURL, but containing the information in the body:

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

So, you need to figure out how they are generated and what they mean and then reproduce it 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, perhaps some information may not be sent, but this will have to be tested one by one. p>

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

    
13.06.2017 / 08:09