jQuery on the fly URL shortener

Here is an example how to get a shortened URL with Bitly API and jQuery: function get_short_url(long_url, login, api_key, func) { $.getJSON( “http://api.bitly.com/v3/shorten?callback=?”, { “format”: “json”, “apiKey”: api_key, “login”: login, “longUrl”: long_url }, function(response) { func(response.data.url); } ); } The following code could be used to get a short URL: /* Sign up for Bitly … Read more

How can I unshorten a URL?

Send an HTTP HEAD request to the URL and look at the response code. If the code is 30x, look at the Location header to get the unshortened URL. Otherwise, if the code is 20x, then the URL is not redirected; you probably also want to handle error codes (4xx and 5xx) in some fashion. … Read more