Login To Facebook Using PHP cURL

0 votes

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;

?>
Aug 6, 2022 in PHP by Kithuzzz
• 38,010 points
1,964 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How can I connect to a Tor hidden service using CURL in PHP?

Hello @kartik, I use Privoxy and cURL to scrape Tor ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,880 points
4,988 views
0 votes
1 answer

How to get response using cURL in PHP?

Hello @kartik, Use the below piece of code ...READ MORE

answered Oct 19, 2020 in PHP by Niroj
• 82,880 points
6,412 views
0 votes
1 answer

How to retrieve or obtain data from the MySQL database using PHP?

Hello kartik,  Actually there are many functions that  ...READ MORE

answered Mar 27, 2020 in PHP by Niroj
• 82,880 points
3,083 views
0 votes
1 answer

How to send email using php?

Hello @kartik 1.) Download PHPMailer, open the zip file ...READ MORE

answered Apr 1, 2020 in PHP by Niroj
• 82,880 points
1,067 views
0 votes
1 answer

How to zip a whole folder using PHP?

Hello @kartik, You can Zip a whole folder using ...READ MORE

answered Aug 24, 2020 in PHP by Niroj
• 82,880 points
7,734 views
0 votes
1 answer

How to post data in PHP using file_get_contents?

Hello @kartik, Sending an HTTP POST request using file_get_contents is ...READ MORE

answered Aug 24, 2020 in PHP by Niroj
• 82,880 points
6,644 views
0 votes
2 answers

Using PHP to get all file names in a folder stored in HDFS

So i found a workaround for the ...READ MORE

answered Mar 13, 2019 in Big Data Hadoop by Bhavish
• 370 points

edited Mar 13, 2019 by Omkar 3,762 views
0 votes
0 answers

PHP, cURL, and HTTP POST example?

I needed t to send data like ...READ MORE

Jun 1, 2022 in PHP by Kichu
• 19,050 points
376 views
0 votes
0 answers

php extension mcrypt must be loaded

When I tried to install Magento on ...READ MORE

Jun 16, 2022 in PHP by narikkadan
• 63,700 points
297 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP