PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Andre Roque Filipe   oGravatar   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: oGravatar
Get avatar images and the profile of Gravatar user
Author: By
Last change: Update of example.php
Date: 11 months ago
Size: 1,390 bytes
 

Contents

Class file image Download
<?php

/**
 * oGravatar example file
 *
 * @package oGravatar
 * @author AndrĂ© Filipe <andre.r.flip@gmail.com>
 * @link https://github.com/ReiDuKuduro/oGravatar Github Repo
 * @license MIT
 * @version 1.0
 */

require_once 'oGravatar.php';

$my_gravatar = new oGravatar('andre.r.flip@gmail.com');

$my_gravatar->setSize(200);

$my_gravatar->setRating(oGravatar::RATING_X);

$my_gravatar->setDefault(oGravatar::DEFAULT_MONSTERID);

$attributes = array(
   
'id' => 'my_gravatar_image',
   
'class' => 'some_random_class or-not',
   
'style' => 'height: 200px',
   
'width' => '200px',
);
echo
$my_gravatar->getAvatar($attributes);

echo
'<br>';

echo
$my_gravatar->getAvatarUrl();

echo
'<br>';

$my_gravatar->getProfile();

if (
$my_gravatar->has_profile) {
    echo
'<pre>';
   
print_r($my_gravatar);
    echo
'</pre>';
} else {
    echo
"This email doesn't have a gravatar account";
}

/*

//Chaining stuff
$my_gravatar = new oGravatar('andre.r.flip@gmail.com', true);

$attributes = array(
    'id' => 'my_gravatar_image',
    'class' => 'some_random_class or-not',
    'style' => 'height: 200px',
    'width' => '200px',
);

echo $my_gravatar->setSize(200)
                 ->setRating(oGravatar::RATING_X)
                 ->setDefault(oGravatar::DEFAULT_MONSTERID)
                 ->getAvatar($attributes);
//*/