PHP Classes

Gravatar PHP: Get the URL, image and profile of a Gravatar user

Recommend this page to a friend!
  Info   View files Example   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 102 All time: 9,730 This week: 115Up
Version License PHP version Categories
gravatar-php 0.1.0MIT/X Consortium ...3.0PHP 5, User Management, Web services
Description 

Author

This class can get the URL, image and profile of a Gravatar user.

It can take the email address of a given gravatar user and it can generate the URL of his avatar image either in PNG or JPEG formats.

The class can also generate HTML to show the avatar in a Web page.

It can also send HTTP requests to retrieve the user profile public information in several formats: PHP, JSON, XML, VCF and QRCode.

Picture of Ravi Kumar
  Performance   Level  
Name: Ravi Kumar is available for providing paid consulting. Contact Ravi Kumar .
Classes: 6 packages by
Country: India India
Age: 40
All time rank: 1720101 in India India
Week rank: 346 Up19 in India India Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php

   
/**
     * This file is only used for demo purpose.
     *
     * @package Gravatar
     * @author Ravi Kumar
     * @version 0.1.0
     * @copyright Copyright (c) 2014, Ravi Kumar
     * @license https://github.com/ravikumar8/Gravatar/blob/master/LICENSE MIT
     **/

   
include_once 'vendor/autoload.php';

   
$email = 'webloper@gmail.com';

   
$gravatar = new \Gravatar\Gravatar( $email );

    
$url = $gravatar->setSize(200)->url();

    
$profile = $gravatar->profile('xml');

   
$name = 'Gravatar Image';
   
$xml = $profile->xpath( '//entry/name/formatted' );
    if (
is_array( $xml ) && isset( $xml[0] ) )
       
$name = (string) $xml[0];

    
$img = $gravatar->img( array( 'alt' => $name ) );
?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Gravatar</title>
        <style>
            body { font: 1em "Trebuchet MS", sans-serif; }
            .comments { width: 100%; }
            .comment { padding: 10px 10px 0 10px; }
            .comment:after { content: ' '; display: table; clear: both; }
            .comment-image { width: 65px; }
            .comment-image img { width: 50px; border-radius: 50px; }
            .comment-image, .comment-body { float: left; }
            .comment-body { width: 80%; }
            .comment-body p { margin-top: 10px; }
            .comment-info { font-weight: bold; }
            .comment-reply { margin-left: 5%; }
        </style>
    </head>
    <body>

         <div class="comments">
            <div class="comment">
                <div class="comment-image">
                    <?php echo $img; ?>
</div>
                <div class="comment-body">
                    <div class="comment-info">Ravi said 2 min ago</div>
                    <p>Toffee chupa chups <a href="<?php echo $url; ?>">Gravatar Url</a> gummi bears wafer topping macaroon icing. Ice cream apple pie carrot cake sesame snaps marshmallow halvah unerdwear.com cheesecake. Lollipop dragée candy canes bonbon gummies. Candy candy sweet dragée pastry. Powder jujubes jelly beans carrot cake unerdwear.com sesame snaps sweet dragée.</p>
                </div>
            </div>
            <div class="comment comment-reply">
                <div class="comment-image">
                    <?php echo $img; ?>
</div>
                <div class="comment-body">
                    <div class="comment-info">Ravi said 2 min ago</div>
                    <p>Toffee chupa chups unerdwear.com gummi bears wafer topping macaroon icing. Ice cream apple pie carrot cake sesame snaps marshmallow halvah unerdwear.com cheesecake. Lollipop dragée candy canes bonbon gummies. Candy candy sweet dragée pastry. Powder jujubes jelly beans carrot cake unerdwear.com sesame snaps sweet dragée.</p>
                </div>
            </div>
        </div>

    </body>
</html>


Details

Gravatar

Author Source Code Latest Version Software License Build Status Code Coverage Quality Total Downloads

Gravatar url, image and profile data

A small library intended to provide easy integration of... Gravatar :)

It will help you generate the URL for Gravatar images and also provide img tag as well as user profile data in json, xml, php, vcf or qr format.

Highlights

Thanks! :sparkling_heart:


  Files folder image Files  
File Role Description
Files folder imagesrc (2 files, 1 directory)
Files folder imagetests (1 file)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageException (4 files)
  Plain text file Exception.php Class Class source
  Plain text file Gravatar.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Plain text file EmailRequiredException.php Class Class source
  Plain text file InvalidArgumentsException.php Class Class source
  Plain text file InvalidEmailException.php Class Class source
  Plain text file InvalidFormatException.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file GravatarTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:102
This week:0
All time:9,730
This week:115Up