Veerasundaravel's Ruby on Rails Weblog

December 2, 2010

Gravatar Profile in Rails using gravatar_profile gem

Filed under: Gravatar — Tags: , , , , , , — Veerasundaravel @ 5:40 pm

This article is about getting Gravatar profile information like gravatar_image, profile_url and display name etc.,

Gravatar APIs require no authentication, you can get profile information by simple HTTP GET requests. You should pass the user email address to the API and the API will return the corresponding registered users details.


GravatarProfile Gem:

Here we are going the gem gravatar_profile to interact with Gravatar API.

gravatar_profile is a Ruby Wrapper for getting GRAVATAR avatars and profile informations.

By passing the user email you can get the gravatar image, gravatar profile url and as well as profile informations also.

gem install gravatar_profile


Getting Gravatar Image:

gravatar ="your-email-address")

>> ""


Getting Gravatar Profile Url:

gp ="your-email-address")

>> ""

gp.gravatar_profile_url(:filetype => :xml)
>> ""


Accessing profile informations:

#Accessing profile information is much simpler, just you need to call the function get_profile_info and it will return entire information of the gravatar user as a hash.

gp ="some-email-address")

#It will return a collection of profile information as Hash from gravatar.

#If your server need to use proxyy means specify the proxy details as follows.
gp.get_profile_info({:proxy_host => '', :proxy_port=>8000})

>> {"name"=>[{"givenName"=>["User-GivenName"], "familyName"=>["FamilyName"], "formatted"=>["User-GivenName Lastname"]}], "requestHash"=>["6fa14cea067256804121f81c33d5fbb"], "preferredUsername"=>["user-givenname"], "displayName"=>["user-givenname"], "thumbnailUrl"=>[""], "hash"=>["6fadss14cea0167256804121f81c33d5fbb"], "urls"=>[{"value"=>[""]}, {"title"=>["Ruby on Rails Weblog"], "value"=[""]}, {"title"=>["Twitter Account"], "value"=>[""]}], "ims"=>[{"type"=>["yahoo"], "value"=>["some-name2003"]} {"type"=>["gtalk"], "value"=>["some-name2003"]}, {"type"=>["skype"], "value"=>["user-givenname"]}], "emails"=>[{"primary"=>["true"], "value"=>[""]}], "photos">[{"type"=>["thumbnail"], "value"=>[""]}, {"value"=>[""]}], "id"=>["5146707"], "accounts"=>[{"shortname"=>["facebook"], "url"=>[""], "username"=>[""], "domain"=>["], "display"=>[""], "verified"=>["true"]}, {"shortname"=>["linkedin"], "url"=>[""], "username"=>["usernameel"], "domain"=>[""], "display"=>["user-givenname"], "verified"=>["true"]}, {"shortname"=>["twitter"], "url"=>[""], "username"=>["eerasundaravel"], "domain"=>[""], "display"=>["@user-givenname"], "verified"=>["true"]}, {"shortname"=>["wordpress"], "url"=>["", "username"=>[""], "domain"=>[""], "display"=>[""], "verified"=>["true"]}], "currentLocaton"=>["Location1, Country"], "aboutMe"=>["About me text goes here"], "phoneNumbers"=>[{"type"=>["mobile"], "value"=>["9894873774"]}], "profileUrl"=>[""]}

%d bloggers like this: