<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://www.sharejs.com');
</script>
//javascript/8237