Answer the question
In order to leave comments, you need to log in
Check by email if there is a gravatar?
Hello everyone, how can I check if there is an email engraver or not?
<?php
$email = $review['email'];
$default = "https://www.somewhere.com/homestar.jpg";
$size = 50;
$grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;
?>
Answer the question
In order to leave comments, you need to log in
function isGravatar($email) {
$uri = 'https://www.gravatar.com/avatar/' . md5($email) . '?d=404';
$headers = get_headers($uri);
return (bool) preg_match("|200|", $headers[0]);
}
// isGravatar('[email protected]');
Found solution on google
<?php
$email = $review['email'];
$hash = md5($email);
$uri = 'http://www.gravatar.com/avatar/' . $hash . '?d=404';
$default = "https://www.somewhere.com/homestar.jpg";
$size = 50;
$headers = @get_headers($uri);
if (!preg_match("|200|", $headers[0])){
$grav_url = "catalog/view/theme/tbchoice/img/comment2.jpg";
} else {
$grav_url = "https://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question