Home
> Uncategorized > Get the #Google #avatar image from an email address in #PHP
Get the #Google #avatar image from an email address in #PHP
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.
Categories: Uncategorized
Informative article, exactly what I wass looking for.
LikeLike