Created
May 13, 2014 16:31
-
-
Save ortense/ee19c886164d26cadde8 to your computer and use it in GitHub Desktop.
Function to shorten url by bit.ly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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