I'm trying to make a URL Shortener tool for my web application using the Bitly API.
I found an SO thread here and saw what seemed to be simple enough jQuery solution.
getShortUrl: function(url, callback){
var accessToken = //My access token, I've signed up at the site
var url = 'https://api-ssl.bitly.com/v3/shorten?access_token=' + accessToken + '&longUrl=' + encodeURIComponent(url);
$.getJSON(
url,
{},
function(response)
{
if(callback)
callback(response.data.url);
}
);
},
alert(getShortUrl("https://stackoverflow.com/search?q=URL+Shortener+JavaScript"))
I'm testing this out in chromium dev tools. The code doesn't error but the alert always comes out as undefined.