Skip to content

Instantly share code, notes, and snippets.

@Sitebase
Created November 13, 2014 12:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sitebase/6f87f414c9c7de128311 to your computer and use it in GitHub Desktop.
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.
var http = require('http'),
md5 = require('MD5');
var options = {
method: 'HEAD',
host: 'www.gravatar.com',
port: 80,
path: '/avatar/' + md5('info@blabla.be') + '?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