fetchAvatar() public method

Fetch the avatar image.
public fetchAvatar ( string $mail, mixed $opts = [] ) : resource
$mail string The mail address.
$opts mixed Additional options. See getAvatarUrl().
return resource The image as stream resource, or null if the server returned an error.
Beispiel #1
0
 /**
  */
 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;
 }
Beispiel #2
0
<?php

require_once 'Horde/Autoloader/Default.php';
$g = new Horde_Service_Gravatar();
file_put_contents('/tmp/avatar.jpg', $g->fetchAvatar('*****@*****.**'));