23. Challenge 1 - Solution

Using the Zinc HTTP library, get a photo from an email address through gravatar http://www.gravatar.com/avatar/. Convert it into a morph and open it in Pharo. Using stephane.ducasse@inria.fr so that you are sure to get a .jpg. The result should look like situation shown in the figure below.

23.0.1. Hints:

  • The path to the photo associated to an email is composed as follows: http://www.gravatar.com/avatar/(MD5 email-based hex).jpg
  • To build an MD5 cypher from the email use MD5 hashMessage: .Pay attention that you should convert its result in hexadecimal.
  • Do not forget to trim blanks around the email and use it in lower case.
  • asMorph convert pictures into Morphs.
  • Message openInHand is fun.

23.0.2. Solution

	| email url |
	email := 'stephane.ducasse@inria.fr'. 
	url := 'http://www.gravatar.com/avatar/', (MD5 hashMessage: email trimBoth asLowercase) hex, '.jpg'. 
	(ZnEasy getJpeg: url) asMorph openInHand.  

Grabbing the gravatar associated with stephane.ducasse@inria.fr .