Last active
December 11, 2015 00:49
-
-
Save onozaty/4519326 to your computer and use it in GitHub Desktop.
Google URL Shortener
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
var request = new XMLHttpRequest(); | |
request.onreadystatechange = function() { | |
if (request.readyState == 4) { | |
if (request.status == 200) { | |
console.log(request.responseText); | |
} else { | |
console.log('error!! status code:' + request.status); | |
} | |
} | |
}; | |
request.open( | |
'POST', | |
'https://www.googleapis.com/urlshortener/v1/url?key={your API Key}', | |
true); | |
request.setRequestHeader('Content-Type', 'application/json'); | |
request.send("{'longUrl': 'http://www.google.com/'}"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment