Dmitry Baranovskiy’s Blog α




Avatar from flickr™

12 December 2006

I have recently disabled the gravatar support for my avatars on the blog comments page as it just runs too slow. However the flickr avatars still work. Some people have asked me how it works. It is not a big secret and you can find it out by reading the specs on the flickr API. But for you, lazy busy people I’ll print the algorithm I use:

  1. You can get the XML from this url:
    http://www.flickr.com/services/rest/?method=flickr.people.findByEmail&api_key= ‹api_key›&find_email= ‹email@address›
    This XML will return to you the person if they registered on flickr via their entered e-mail address.
  2. From here you can grab user’s User ID using XPath: /rsp/user/@nsid
    We will use this information later.
  3. Then we get another XML:
    http://www.flickr.com/services/rest/?method=flickr.people.getInfo&api_key= ‹api_key›&user_id= ‹User ID›
    Here we try to find out the Server ID of the person. It is an internal flickr structure but it is important.
  4. Grab Server ID. XPath: /rsp/person/@iconserver
  5. Follow this link:
    http://static.flickr.com/‹Server ID›/buddyicons/‹User ID›.jpg
    this is the avatar!
    But beware: the returned avatar could just be a calm grey face as the default avatar used in flickr is still considered an avatar and so will be returned.

Feel free to implement this with your favourite back-end scripting language on your own blog.

, ,

14 Dec 06 12:01am

R Walker

It seems Gravatar are aware of there “slowness”. The <a href=“http://www.gravatar.com/“> Gravatar homepage</a> tells the full story.
18 Dec 06 12:31pm

Kevin Donahue

This is awesome, Dmitry. I wish I understood the code well enough to craft a php script include or wordpress plugin.

Any tips?
25 Dec 06 10:52pm

Ricky Moorhouse

Thats a great idea – I was getting fed up with the gravatar slowness, and the new default image.
I’ve got a very rough wordpress plugin of it working – I’ve just got to add an options page to specify the API key, and I’ll probably release it.