I’m trying to check if a gravatar exists. When I try the approach recommended in earlier questions, I get an error ” Warning: get_headers() [function.get-headers]: This function may only be used against URLs” Anyone seen this or see the error in my code? PS I do not want to specify a default image for gravatar to serve as there could be more than one default possibilities if no gravatar exits.
Also, I found a reference to error possibly being related to my ini file which I don’t think my host gives me access to. If so, is there an alternative to getheaders? Many thanks.
$email = $_SESSION['email'];
$email= "person@gmail.com"; //for testing
$gravemail = md5( strtolower( trim( $email ) ) );
$gravsrc = "http://www.gravatar.com/avatar/".$gravemail;
$gravcheck = "http://www.gravatar.com/avatar/".$gravemail."?d=404";
$response = get_headers('$gravcheck');
echo $response;
exit;
if ($response != "404 Not Found"..or whatever based on response above){
$img = $gravsrc;
}
Observation
A.
get_headers('$gravcheck');would not work because of use of single quote'B. calling
exit;would terminate script prematurelyC.
$responsewould return an array you can not useechoto print the information useprint_rinstedD.
$response != "404 Not Found"would not work because$responseis arrayThis is the proper way to do it :