Skip to content

Instantly share code, notes, and snippets.

@RobinRojowiec
Created February 22, 2019 21:58
Show Gist options
  • Save RobinRojowiec/266d24f132d6c66a96c6bd9304a60de5 to your computer and use it in GitHub Desktop.
Save RobinRojowiec/266d24f132d6c66a96c6bd9304a60de5 to your computer and use it in GitHub Desktop.
/* Load the packages for hashing and HTTP requests (must be installed with npm before) */
var crypto = require("crypto");
var request = require("request");
/* Generate a md5-hash of a email address and return its hexadecimal value */
var hash = crypto.createHash('md5').update("example@hotmail.com").digest("hex");
/* Sends a GET request for the user profile */
request("https://www.gravatar.com/"+hash+".xml",function(err,response,body){
if (!err){
console.log(body);
}else{
console.log("Error: "+err);
}
})
/* Sends a GET request for the avatar */
request("https://www.gravatar.com/avatar/"+hash+".jpg",function(err,response,body){
if (!err){
console.log("Got image: "+body);
}else{
console.log("Error: "+err);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment