/** */ public function avatarImg($email) { if (class_exists('Horde_Service_Gravatar')) { $gravatar = new Horde_Service_Gravatar(Horde_Service_Gravatar::STANDARD, $GLOBALS['injector']->getInstance('Horde_Http_Client')); $data = $gravatar->fetchAvatar($email, array('default' => 404, 'size' => 80)); if (!is_null($data)) { rewind($data); $img_data = stream_get_contents($data); if (strlen($img_data)) { return array('desc' => '', 'url' => Horde_Url_Data::create('image/jpeg', $img_data)); } } } return null; }
<?php require_once 'Horde/Autoloader/Default.php'; $g = new Horde_Service_Gravatar(); print Horde_Yaml::dump($g->getProfile('*****@*****.**'));
public function testFlexibleBase() { $g = new Horde_Service_Gravatar(Horde_Service_Gravatar::SECURE); $this->assertEquals('https://secure.gravatar.com/0c17bf66e649070167701d2d3cd71711', $g->getProfileUrl(' Test@Example.orG ')); }
public function testGetProfile() { $g = new Horde_Service_Gravatar($this->_server); $profile = $g->getProfile('*****@*****.**'); $this->assertEquals('http://gravatar.com/abc1xyz2', $profile['entry'][0]['profileUrl']); }
<?php require_once 'Horde/Autoloader/Default.php'; $g = new Horde_Service_Gravatar(); file_put_contents('/tmp/avatar.jpg', $g->fetchAvatar('*****@*****.**'));
<?php require_once 'Horde/Autoloader/Default.php'; $g = new Horde_Service_Gravatar(); print $g->fetchProfile('*****@*****.**');