Created
July 30, 2013 08:10
-
-
Save romeoh/6111170 to your computer and use it in GitHub Desktop.
goo.gl
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
<script type="text/javascript"> | |
function getShortUrl(url) { | |
var tdata = '{"longUrl": "' + url + '"}'; | |
$.support.cors = true; | |
$.ajax({ | |
url: "https://www.googleapis.com/urlshortener/v1/url", | |
type: "POST", | |
dataType: "json", | |
data: tdata, | |
contentType: "application/json", | |
success: function (result) { | |
var shortUrl = result.id; | |
console.log(result); | |
}, | |
error : function(request,status,error) { | |
//console.log("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); | |
} | |
}); | |
} | |
getShortUrl('http://romeoh.github.io/kakaoStory/html/gawibawibo.html'); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment