Last active
November 28, 2017 19:24
-
-
Save sketchthat/ae60aece1c5c7e7932e65c2519518dd8 to your computer and use it in GitHub Desktop.
Use bitly to generate a short URL with jQuery.
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
// Generate Access Token | |
// https://bitly.com/a/oauth_apps | |
var shortenUrl = function(accessToken, longUrl) { | |
$.getJSON('https://api-ssl.bitly.com/v3/shorten', { | |
access_token: accessToken, | |
longUrl: longUrl | |
}) | |
.success(function(resp) { | |
console.log('URL: ', resp.data.url); | |
}) | |
.error(function(err) { | |
console.error(err); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment