Skip to content

Instantly share code, notes, and snippets.

@ortense
Created May 13, 2014 16:31
Show Gist options
  • Save ortense/ee19c886164d26cadde8 to your computer and use it in GitHub Desktop.
Save ortense/ee19c886164d26cadde8 to your computer and use it in GitHub Desktop.
Function to shorten url by bit.ly
/**
* @function bitLy
* @param {string} long_url - Long URL to shorten
* @param {function} func - receives short url
*/
function bitLy(long_url, func){
$.getJSON(
"http://api.bitly.com/v3/shorten?callback=?",
{
"format": "json",
"apiKey": "your_api_key",
"login": "your_login",
"longUrl": long_url
},
function(response)
{
func(response.data.url);
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment