Skip to content

Instantly share code, notes, and snippets.

@sketchthat
Last active November 28, 2017 19:24
Show Gist options
  • Save sketchthat/ae60aece1c5c7e7932e65c2519518dd8 to your computer and use it in GitHub Desktop.
Save sketchthat/ae60aece1c5c7e7932e65c2519518dd8 to your computer and use it in GitHub Desktop.
Use bitly to generate a short URL with jQuery.
// 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