I'm trying to write a login function using PHP CURL to perform a login in the following site: https://partners.mrfavorit.com/. When I look at the network requests, it seems that the platform is on .NET.
First I make one GET request to collect cookies:
$ch = curl_init();
curl_setopt_array( $ch, array(
CURLOPT_URL => 'https://partners.mrfavorit.com/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HEADER => true,
));
$a = curl_exec($ch);
preg_match_all('|Set-Cookie: (.*);|U', $a, $results);
$cookies2 = implode(';', $results[1]);
then I send POST with the login credentials to the same URL, but it doesn't work, request returns 200 with the login page html code.
curl_setopt_array($ch, array(
CURLOPT_URL => "https://partners.mrfavorit.com/?&txtUserName=myusername&txtPassword=mypassword123",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HEADER => true,
CURLOPT_POSTFIELDS =>'',
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Cookie: ".$cookies2
),
));
$r2 = curl_exec($ch);
print_r($r2);
What could be the reason for this to be failing?
The final purpose for this is to collect data from the report tables inside the system.