Tutorial: Getting Gravatars – MD5 Encryption And Simple Data Retrieval

In the past I’ve posted about how to extra data from web services, particularly parsing XML and JSON.  Some web services are much simpler than this, and don’t require that level of overhead.  An example of this service is the Gravatar service (for those who don’t know those little images you see beside comments are typically from users registered on Gravatar.com).

In order to get a gravatar all you need to do is encrypt the user’s e-mail into an MD5 hash, add that information to a URL associated with the gravatar api, and in return gravatar.com will send you the URL of the image.

Mugunth Kumar has created a tutorial illustrating this process here:
Add Gravatar Support To Your App

Here’s the blood and guts of it:

1. The “CommonCrypto/CommonDigest.h” includes a function known as CC_MD5 which allows you to convert the user’s e-mail into a MD5 hash tag.

2.From there it’s simply a matter of accessing the URL on gravatar at “http://www.gravatar.com/avatar/HASH” and that will give you the URL of the user’s avatar.

Mugunth has also added a sample project on Github:
http://github.com/MugunthKumar/Gravatar

There probably aren’t many situations when you’ll specifically need Gravatars in your app, but it’s especially good to know how to perform the MD5 encryption, as it is commonly required by web api’s.

Thanks for reading, please share this using the buttons below!

[Via: Under The Bridge]

©2010 iPhone, iOS 4, iPad SDK Development Tutorial and Programming Tips. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Leave a Reply

Your email address will not be published. Required fields are marked *