I need to login facebook with curl. I already tested in browser with condition disable cookie, javascript and Opera mini 4 User-agent. It login succefully. with that i check with inspect what happens within request header and response headers. i check it already. the first step facebook will generate 4 random values within hidden type input "lsd, jazoest,m_ts,li". the second step after post it will redirect to specific location with session. Cause, i disable cookie. so i see facebook switch to session. after this step. i should see my timeline page. but, it nothing happens. it just post to login page without follow location. object httpConnect is wrapper from curl.
$headers = [
'User-agent: Opera/9.80 (J2ME/MIDP; Opera Mini/4.0.10992/35.5561; U; hr) Presto/2.8.119 Version/11.10',
];
$facebook = new httpConnect('https://m.facebook.com/');
$facebook->setHeaders($headers);
$facebook->setOptions();
$facebook->sendRequest();
$sourceCode = $facebook->getResponse();
preg_match('/<input type="hidden" name="lsd" value="(.*?)" autocomplete="off" \/>/', $sourceCode, $lsd);
preg_match('/<input type="hidden" name="jazoest" value="(.*?)" autocomplete="off" \/>/', $sourceCode, $jazoest);
preg_match('/<input type="hidden" name="m_ts" value="(.*?)" \/>/', $sourceCode, $m_ts);
preg_match('/<input type="hidden" name="li" value="(.*?)" \/>/', $sourceCode, $li);
$data = [
'lsd' => $lsd[1],
'jazoest' => $jazoest[1],
'm_ts' => $m_ts[1],
'li' => $li[1],
'try_number' => 0,
'unrecognized_tries' => 0,
'email' => 'email',
'pass' => 'password',
'login' => 'Log In',
'_fb_noscript' => 'true'
];
$options = [
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => $data,
CURLOPT_FOLLOWLOCATION => TRUE,
];
$facebook = new httpConnect('https://m.facebook.com/login/device-based/regular/login/?refsrc=https%3A%2F%2Fm.facebook.com%2F&lwv=100&refid=8');
$facebook->setHeaders($headers);
$facebook->setOptions($options);
$facebook->sendRequest();
echo $facebook->getResponse();