2017 © Pedro Peláez
 

library gravatar

PHP library for gravatar.com

image

emanueleminotto/gravatar

PHP library for gravatar.com

  • Sunday, October 11, 2015
  • by EmanueleMinotto
  • Repository
  • 1 Watchers
  • 0 Stars
  • 605 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Gravatar

Build Status SensioLabs Insight Coverage Status Scrutinizer Code Quality Total Downloads, (*1)

PHP library for gravatar.com based on Guzzle 5., (*2)

API: emanueleminotto.github.io/Gravatar, (*3)

Install

Install Silex using Composer., (*4)

Install the Gravatar library adding emanueleminotto/gravatar to your composer.json or from CLI:, (*5)

$ composer require emanueleminotto/gravatar

Usage

This library exposes 5 APIs:, (*6)

use EmanueleMinotto\Gravatar\Client;

$client = new Client(/* optional Guzzle HTTP client */);

// user profile
$url = $client->getProfileUrl('user@example.com'); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json
$qrcode = $client->getProfileUrl('user@example.com', 'qr'); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr
$qrcode = $client->getProfileUrl('user@example.com', 'json', [
    'callback' => 'alert',
]); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json?callback=alert

$profile = $client->getProfile('user@example.com');
// array(
//   "id" => "b58996c504c5638798eb6b511e6f49af",
//   "hash" => "b58996c504c5638798eb6b511e6f49af",
//   "preferredUsername" => "example user",
//   ...
// )

// user avatar
$img = $client->getAvatarUrl('user@example.com'); // https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.jpg?d=404&r=g&s=80
$img = $client->getAvatarUrl('user@example.com', 150); // https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.jpg?d=404&r=g&s=150

$img = $client->getAvatar('user@example.com'); // data URI
$img = $client->getAvatar('user@example.com', 150); // data URI

$exists = $client->exists('user@example.com'); // true
$exists = $client->exists('wrong'); // false

Twig Extension

In this library there's included a Twig extension to allow a simple integration with frameworks., (*7)

{% if email is gravatar %} {# this test check if the gravatar exists #}
    <a href="{{ email|gravatar_profile_url }}">
        <img
            src="{{ email|gravatar_url }}"
            alt="{{ gravatar_profile(email).profileUrl }}"
        />
    </a>
{% endif %}

The Versions

11/10 2015

dev-master

9999999-dev

PHP library for gravatar.com

  Sources   Download

MIT

The Requires

 

The Development Requires

twig gravatar

01/02 2015

1.1.0

1.1.0.0

PHP library for gravatar.com

  Sources   Download

MIT

The Requires

 

The Development Requires

twig gravatar

31/01 2015

1.0.0

1.0.0.0

PHP library for gravatar.com

  Sources   Download

MIT

The Requires

 

The Development Requires

gravatar