判断gravatar是否有头像

Gravatar是一图像跟随著您到访过的网站,当您在博客中留言或发表文章,它将会出现在您的名称旁。头像协助识别您在博客和论坛发表的文章,何乐而不为呢?全球公认的头像网站,利用你的邮件号码来读取你在Gravatar里设置的头像,大部分用原生评论的博客都是支持Gravatar头像的。。。注册网站http://cn.gravatar.com/
今天发现之前写的判断方法有问题。。。
度娘了一下。。发现了个更好的方法。。。
$hash = md5(trim($mail)); $uri = 'http://cn.gravatar.com/avatar/'.$hash.'?d=404'; $headers = @get_headers($uri); if (!preg_match("|200|", $headers[0])) {//没头像 return 'https://blog.hellozwh.com/moren.jpg'; }else { return "http://cn.gravatar.com/avatar/$hash?s=40&d=mm&r=g"; }



本文作者:起点终站
文章标题: 判断gravatar是否有头像
本文地址:https://blog.hellozwh.com/?post=264
版权声明:若无注明,本文皆为“起点终站”原创,转载请保留文章出处。
本文地址:https://blog.hellozwh.com/?post=264
版权声明:若无注明,本文皆为“起点终站”原创,转载请保留文章出处。


