HTTP Error 403
I am currently getting this error from hibp -f info.txt:
Hibp::HttpClient::ClientError: GET to https://haveibeenpwned.com/api/breachedaccount/<email> returned status 403 - options: {:query=>nil}
Same, not sure what is wrong
Same here!
403 | Forbidden — no user agent has been specified in the request
(from API documentation) I'd like to know how to specify a "user agent", any idea?
Bummer. Just came across this too... No update or idea on how to avoid this?
Folks, everyone is getting 403 for the following reason: "Specifying the user agent Each request to the API must be accompanied by a user agent request header. Typically this should be the name of the app consuming the service. A missing user agent will result in an HTTP 403 response."
GET https://haveibeenpwned.com/api/{service}/{parameter} User-Agent: [your app name]
I've used the following code and worked well, any problem!
$agent = array('http' => array('user_agent' => 'any code here')); //could be the initial letters of your name
$curl = curl_init('https://haveibeenpwned.com/api/v2/breachedaccount/test@example); //Creates a new cURL resource
curl_setopt($curl, CURLOPT_USERAGENT, $agent ); //Set URL options, CURLOPT_URL is the URL to fetch at $path
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); //Set URL options, true to return transfer as a string
$xmlResponse = curl_exec($curl); //Execute the given cURL session after options are set $info = curl_getinfo($curl); //Get information about the transfer
curl_close($curl); //Close cURL resource
$hibp_result=json_decode($xmlResponse,true); //Convert a string to a PHP variable