8

Where should I start if I want to integrate Gravatars for the users in my Java application?

MasterMastic
  • 20,711
  • 12
  • 68
  • 90
MatBanik
  • 26,356
  • 39
  • 116
  • 178

3 Answers3

17

You can use jgravatar and than just use methods like the once bellow:

import jgravatar.Gravatar;
import jgravatar.GravatarDefaultImage;
import jgravatar.GravatarRating;

public static String getGravatar160pxUrl(String email) {
    Gravatar gravatar = new Gravatar();
    gravatar.setSize(160);
    gravatar.setRating(GravatarRating.GENERAL_AUDIENCES);
    gravatar.setDefaultImage(GravatarDefaultImage.IDENTICON);
    return gravatar.getUrl(email);
}

public static String getGravatar80pxUrl(String email) {
    Gravatar gravatar = new Gravatar();
    gravatar.setRating(GravatarRating.GENERAL_AUDIENCES);
    gravatar.setDefaultImage(GravatarDefaultImage.IDENTICON);
    return gravatar.getUrl(email);
}
3

if anyone interested, here comes Android version too...

hope this helps...
https://github.com/wareninja/gravatar-for-android

Android library for Gravatar stuff, current features;

  • Load Gravatar image using AsyncTask
  • Load and Parse Gravatar Profile using AsyncTask
Yilmaz Guleryuz
  • 9,313
  • 3
  • 32
  • 43
  • Is there a reason no updates have been done in 2 years? Gravatar did not evolve? – oldergod Dec 06 '12 at 07:32
  • good question! well... it has been long time that I didn't check gravatar API, i'll revisit and see if any update needed. plz let me know if anything specific is needed, your contribution is also welcome – Yilmaz Guleryuz Dec 07 '12 at 08:24
2

may be you can use my gravatar4j (https://github.com/yingzhuo/gravatar4j)

just do this in you jsp

<%@ taglib prefix="gravatar4j" uri="https://github.com/yingzhuo/gravatar4j/functions" %>

and to this

<img alt="" src="${gravatar4j:from('yingzhor@gmail.com', 160)}">

'160' means size in pixels, by the way.

Zhuo YING
  • 972
  • 3
  • 11
  • 19