PHP 判断 Email 在 Gravatar 有没有自定义头像
<?php
function check_have_avatar($email){
$md5 = md5(strtolower(trim($email)));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.gravatar.com/avatar/{$md5}");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
if(md5($result) === 'd5fe5cbcc31cff5f8ac010db72eb000c'){
return false;
}
return $result;
}
if(!check_have_avatar('ne@nowtime.cc')){
echo '没有自定义头像';
}else{
echo '有自定义头像';
}
如无特别声明,该文章均为 现在网(NowTime.cc
)原创,转载请遵循 署名-非商业性使用 4.0 国际(CC BY-NC 4.0) 协议,即转载请注明文章来源。
赞 (0)