Home > Uncategorized > Get the #Google #avatar image from an email address in #PHP

Get the #Google #avatar image from an email address in #PHP

Screen Shot 2017-08-12 at 16.49.24

This example uses the AvatarAPI.com service, but a new JSON based API which is a bit more modern than the XML / SOAP based API.

<html>
<body>
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => ‘https://www.avatarapi.com/json.aspx/helen.smith@gmail.com‘,
CURLOPT_USERPWD => “arnoldtest:test123″
));
$resp = curl_exec($curl);
curl_close($curl);
$avatar = json_decode($resp);
?>

<img src=”<?php echo $avatar->Image ?>”><br>
<?php echo $avatar->Name ?>

</body>
</html>

The username and password should be substituted with your own username/password which is available at the website.

 

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: