Home > Uncategorized > AvatarAPI.com – Get a name and profile pic from a #Gmail address

AvatarAPI.com – Get a name and profile pic from a #Gmail address

AvatarAPI

Do you find that your users never upload decent profile images?, and you end up with pages with lots of default silhouette icons in place of profile pics?, or perhaps you have a database with plenty of email addresses, but no name to put to them – so you end up sending out emails with “Dear Sir or Madam” instead of “Dear Mr James Smith” , this service at AvatarAPI.com allows you to use a simple API to solve those problems.

It’s easy to implement in either PHP, C#, or any other language that can make a HTTP request and parse XML.

HTTP useage

You can call this via any client capable of making a HTTP request, in it’s simplist form, you make a GET request as follows

http://www.avatarapi.com/avatar.asmx/GetProfile?email=peter.smith@gmail.com&username=xxxxx&password=xxxxx

(where xxxx is your username and password)

And you will receive XML as follows

 

<profile xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://avatarapi.com/”&gt;

<Name>Peter Smith</Name>

<Image>

https://lh3.googleusercontent.com/-06yJmZ9VFKI/AAAAAAAAAAI/AAAAAAAAAAA/KHOss3osMJ4/s181-c/117841766777955842390.jpg

</Image>

<Valid>true</Valid>

</profile>

 

PHP implementation

You can call the webservice via PHP using code such as the following:

Replacing the xxxxx with your username and password.

 

<?php

$client = new SoapClient(“http://www.avatarapi.com/avatar.asmx?wsdl&#8221;);

$params = array (

   “email” => “john.reid@gmail.com”,

   “username” => “xxxxx”,

   “password” => “xxxxxx”

);

$response = $client->__soapCall(‘GetProfile’, array($params));

print_r($response);

?>

 

C# implementation

To use C# to call this API, you must first add a web service reference to your project by right clicking Add > Service Reference, and entering the url http://www.avatarapi.com/avatar.asmx

You can call the namespace “Avatar”, for the purposes of this example, then just add this code into a console app;

Replacing the xxxxx with your username and password.

 

var avatar = new avatarSoapClient();

var profile = avatar.GetProfile(“john.reid@gmail.com”, “xxxx”, “xxxx”);

Console.WriteLine(profile.Name);

Console.ReadLine();

 

Advertisement
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 )

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: