I'm trying to use cURL to log into Facebook, and I'm getting random values from hidden inputs on Facebook to use in post fields like lsd, jazoestm ts, and m ts, but the login process isn't working, and I have no idea why. To continue working on my present project, I need to have a glimpse of the profile.
This Is My PHP Code:
<?php
include("simple_html_domo.php");
//get page data
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://mbasic.facebook.com/login");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13');
$data = curl_exec($ch);
$html = new simple_html_dom();
$html->load($data);
//Scraping from Fields
$lsd = $html->find('input[name=lsd]' , 0)->value;
$jazoest = $html->find('input[name=jazoest]' , 0)->value;
$m_ts = $html->find('input[name=m_ts]' , 0)->value;
$li = $html->find('input[name=li]' , 0)->value;
$try_number = $html->find('input[name=try_number]' , 0)->value;
$unrecognized_tries = $html->find('input[name=unrecognized_tries]' , 0)->value;
$bi_xrwh = $html->find('input[name=bi_xrwh]' , 0)->value;
$login = $html->find('input[name=login]' , 0)->value;
$email = "user123456@myemail.com";
$pass = "password123456";
$postFields = array(
"lsd" => $lsd,
"jazoest" => $jazoest,
"m_ts" => $m_ts,
"li" => $li,
"try_number" =>$try_number,
"unrecognized_tries" =>$unrecognized_tries,
"email" =>$email,
"pass" =>$pass,
"login" =>$login,
"bi_xrwh" => $bi_xrwh
);
//trying to login
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://mbasic.facebook.com/login/device-based/regular/login/?refsrc=deprecated&lwv=100");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_exec($ch);
//profile preview
curl_setopt($ch, CURLOPT_URL, "https://mbasic.facebook.com/profile.php");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$response = curl_exec($ch);
echo $response;
?>