Skip to content

Instantly share code, notes, and snippets.

@gabrielfroes
Created March 19, 2018 17:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielfroes/a67efb28fbf174db60f7861d989830e5 to your computer and use it in GitHub Desktop.
Save gabrielfroes/a67efb28fbf174db60f7861d989830e5 to your computer and use it in GitHub Desktop.
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