Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP client library for Gravatar
<?php
/*-----------------------------------------------------------------------------
* PHP client library for Gravatar
*
* Author: Gabriel Froes
* Copyright: (c) 2018 RW Studio
* License: BSD 3-Clause License
* See accompanying LICENSE file
*
* Version: 1.0
* Updated: -
*-----------------------------------------------------------------------------
*/
class gravatar {
private $_version = '1.0';
private $_url = 'https://www.gravatar.com/avatar/';
private $_size = 40;
private $_default;
public function __construct($params) {
$this->_default = $params['default'];
$this->_size = $params['size'];
}
public function version() {
return $this->_version;
}
// Return gravatar image src
public function get_gravatar($email) {
$img = $this->_url . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $this->_default ) . "&s=" . $this->_size;
return $img;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.