国内公共头像服务CNavatar
1年前
一个头像, 一切无处不在。(至于稳不稳就不得而知了,跑路什么的也是未知,如果要使用请慎重。)
js使用方法
const md5 = require( 'md5' );
function getGravatarURL( email ) {
// Trim leading and trailing whitespace from
// an email address and force all characters
// to lower case
const address = String( email ).trim().toLowerCase();
// Create an MD5 hash of the final string
const hash = md5( address );
// Grab the actual image URL
return `https://www.gravatar.cn/avatar/${ hash }`;
}
php使用方法
function get_gravatar_url( $email ) {
// Trim leading and trailing whitespace from
// an email address and force all characters
// to lower case
$address = strtolower( trim( $email ) );
// Create an MD5 hash of the final string
$hash = md5( $address );
// Grab the actual image URL
return 'https://www.gravatar.cn/avatar/' . $hash;
}
地址:https://www.cnavatar.com
头像调用方法:
https://www.cnavatar.com/avatar/md5(你的邮箱)
如我的头像是
https://www.cnavatar.com/avatar/6cce1b36478bd54ca9d0c7b5667c04fe