Globally Recognized Avatars (Gravatars)

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
andrewbarbour
Newbie
Posts: 14
Joined: Thu Aug 26, 2010 7:09 pm

Globally Recognized Avatars (Gravatars)

Post by andrewbarbour » Wed Mar 30, 2011 3:50 pm

For the past few months I have been using the gravatar service (http://www.gravatar.com) so I do not have to keep updating my avatars on various sites. Your avatar is referenced through a link which uses a hash of your email address. This way any site that has your email address can potentially pull your avatar (very cool!).

For one of the sites I develop we were thinking about using user avatars and potentially using gravatar as the default. Which got me to thinking.. what portion of our current users already have gravatars? Along comes my swiss army knife...... The script below starts from a list of emails and produces a webpage with the gravatars for the full email list. Where there is no gravatar - a default image is loaded. Pretty rudimentary - but if you are considering using gravatars - it is a quick way to see if your friends/users have accounts.

Caution: I am still new to Macrosheduler and not a tech guy - so the script is probably too long and I know there are no error checks, and it does not actually come up with a number for me - but I can 'eyeball' the output.

Code: Select all

// Macro to test for existing Gravatars from a list of email addresses
// setup options
Let>varDir=D:\DATA_Working\Macros\md5\
Let>varSize=16
Let>varRating=PG
// put the list of email addresses in the directory below - one email address per lin
Let>Emaillist=%varDir%Emaillist.txt
Let>outputfile=%varDir%GravatarCheckPage.html
// Create web page
deletefile>outputfile
WriteLn>outputfile,nWLNRes,<html> <html><head><title>MyFolks</title></head><body>
// Read each line, get hash value and output
Let>X=0
Label>FileLoop
Let>X=X+1
ReadLn>Emaillist,X,TexttoHash
If>TexttoHash=##EOF##,finish
Trim>TexttoHash,TexttoHash
LibFunc>%varDir%HashLib.dll,StringMD5,r1,TexttoHash,buf1
MidStr>r1_2,1,r1,Hashed1
LowerCase>Hashed1,Hashed1
WriteLn>outputfile,nWLNRes,<img> %TexttoHash%<br>
goto>FileLoop
Label>finish
MessageModal>Done
// Finish outputting the HTML file
WriteLn>outputfile,nWLNRes,</body></html>

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts