i want to write a script to log in uses curl in PHP. I wrote this code and when i try to use this script, all the time shows message: "Username or Password is incorrect", but if I give this same username and pass, I will log in.
I have no idea what this system requires more, my code now looks like:
$curl=curl_init("http://plemiona.pl/page/auth");
curl_setopt($curl,CURLOPT_HEADER,1);
curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0");
curl_setopt($curl,CURLOPT_REFERER,"http://plemiona.pl/");
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curl, CURLOPT_COOKIEFILE, "D:\cookies.txt");
curl_setopt($curl, CURLOPT_COOKIEJAR, "D:\cookies.txt");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded",
"X-Requested-With: XMLHttpRequest",
"POST /page/auth HTTP/1.1",
"Host: www.plemiona.pl",
"Accept: */*",
"Accept-Language: pl,en-US;q=0.7,en;q=0.3",
"Content-Length: 48"));
curl_setopt($curl, CURLOPT_POST, true);
$postVars = array('username' => 'username',
'password' => 'pass',
'remember' => '0',);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postVars);
$dw=curl_exec($curl);
echo $dw;
When i try manual log in, firefox http headers will show:
My file with cookies after send POST with a curl:
.plemiona.pl TRUE / FALSE 1520687485 cid 705415657
So nothing :(
It is possible that i have to use correct SSL certificate to use: curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE) ? Or what should i search to repair it?