Created
February 22, 2019 21:58
-
-
Save RobinRojowiec/266d24f132d6c66a96c6bd9304a60de5 to your computer and use it in GitHub Desktop.
This file contains 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
/* 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