Skip to content

Instantly share code, notes, and snippets.

@romeoh
Created July 30, 2013 08:10
Show Gist options
  • Save romeoh/6111170 to your computer and use it in GitHub Desktop.
Save romeoh/6111170 to your computer and use it in GitHub Desktop.
goo.gl
<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