Home >php教程 >PHP源码 >远程使用gravatar头像

远程使用gravatar头像

PHP中文网
PHP中文网Original
2016-05-25 17:13:041358browse

远程使用gravatar头像

function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts ='吕滔') {
	$url = 'http://www.gravatar.com/avatar/';
	$url .= md5( strtolower( trim( $email ) ) );
	$e = ROOT_PATH . 'image/user/'.md5( strtolower( trim( $email ) ) ).'.jpg';
	$t = 1209600; 
	$url .= "?s=$s&d=$d&r=$r";
	if ( !is_file($e) || (time() - filemtime($e)) > $t ){//当头像不存在或文件超过14天才更新
		copy($url , $e);//拷贝到本地,一般主机都支持这个函数
	}
	$url=$e;
	if ( $img ) {
		$url = '';
	}
	return $url;
}

使用方法

return get_gravatar($emails,'80','wavatar','g',false);

以上就是远程使用gravatar头像的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php 遍历目录Next article:PHP变量调试函数