Created
November 13, 2014 12:03
-
-
Save Sitebase/6f87f414c9c7de128311 to your computer and use it in GitHub Desktop.
Little trick to check if a gravatar is available or not for a certain email address.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
md5 = require('MD5'); | |
var options = { | |
method: 'HEAD', | |
host: 'www.gravatar.com', | |
port: 80, | |
path: '/avatar/' + md5('[email protected]') + '?d=http://bla.com' | |
}; | |
var req = http.request(options, function(res) { | |
if( res.headers.hasOwnProperty('location') ) { | |
console.log('No gravatar available'); | |
} else { | |
console.log('Gravatar available'); | |
} | |
}); | |
req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment