Answer the question
In order to leave comments, you need to log in
How to login to target.com with PHP?
That just did not try to log in to target.com ... - everything is even.
<?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 = "[email protected]";
$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"
}]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question