Что только не перепробовал что-бы авторизоваться на target.com... - всё четно.
<?php
function clrequest($url, $postdata = null, $cookiefile = 'tmp/cookies.txt')
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0');
//curl_setopt($ch, CURLOPT_PROXY, '192.168.1.104:8887');
//curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiefile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiefile);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
if ($postdata){
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($postdata))
);
}
$html = curl_exec($ch);
curl_close($ch);
return $html;
}
file_put_contents('tmp/cookies.txt', '');
$login = "zuckerberg@facebook.com";
$pass = "dreesunderdress";
$html = clrequest('https://www.target.com/');
$html = clrequest('https://www.target.com/gsp/authentications/v1/credential_validations?client_id=ecom-web-1.0.0', '{"username":"'.$login.'","password":"'.$pass.'"}');
print($html);
?>
Ответ на этот код :
{
"errorCode": "T83072242",
"errorKey": "_ERR_AUTH_DENIED",
"errorMessage": "Please correct the following: Error Code T83072242. Your request was not completed. If you need help, you can call us at 800-316-3111.",
"errorParameters": ""
}
А должен
{
"errors": [{
"errorKey": "_ERR_USER_DOES_NOT_EXIST",
"errorMessage": "Sorry, either your e-mail or password didn't match what we have on file. Try it again?",
"reason": "_ERR_USER_DOES_NOT_EXIST",
"clientId": "ecom-web-1.0.0"
}]
}