PHP code example of emanueleminotto / gravatar
1. Go to this page and download the library: Download emanueleminotto/gravatar library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
emanueleminotto / gravatar example snippets
use EmanueleMinotto\Gravatar\Client;
$client = new Client(/* optional Guzzle HTTP client */);
// user profile
$url = $client->getProfileUrl('[email protected]'); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json
$qrcode = $client->getProfileUrl('[email protected]', 'qr'); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.qr
$qrcode = $client->getProfileUrl('[email protected]', 'json', [
'callback' => 'alert',
]); // https://www.gravatar.com/b58996c504c5638798eb6b511e6f49af.json?callback=alert
$profile = $client->getProfile('[email protected]');
// array(
// "id" => "b58996c504c5638798eb6b511e6f49af",
// "hash" => "b58996c504c5638798eb6b511e6f49af",
// "preferredUsername" => "example user",
// ...
// )
// user avatar
$img = $client->getAvatarUrl('[email protected]'); // https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.jpg?d=404&r=g&s=80
$img = $client->getAvatarUrl('[email protected]', 150); // https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af.jpg?d=404&r=g&s=150
$img = $client->getAvatar('[email protected]'); // data URI
$img = $client->getAvatar('[email protected]', 150); // data URI
$exists = $client->exists('[email protected]'); // true
$exists = $client->exists('wrong'); // false