Ratings | | Unique User Downloads | | Download Rankings |
Not yet rated by the users | | Total: 103 | | All time: 9,771 This week: 455 |
|
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. | |
 |
|
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

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:
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.