Skip to content

Instantly share code, notes, and snippets.

@leejsinclair
Last active December 18, 2015 21:29
Show Gist options
  • Save leejsinclair/5847445 to your computer and use it in GitHub Desktop.
Save leejsinclair/5847445 to your computer and use it in GitHub Desktop.
Quick script that uses bit.ly OAuth api access tokens
var request = require("request");
var BIT_LY_ACCESS_TOKEN = "YOUR_APP_ACCESS_TOKEN" /* See: https://bitly.com/a/oauth_apps# */
, BIT_LY_SHORTEN_URL = "https://api-ssl.bitly.com/v3/shorten";
var shareUrl = "http://www.google.com/";
var options = { "qs": { "access_token": BIT_LY_ACCESS_TOKEN, "longUrl": shareUrl }, "json": true };
request.get( BIT_LY_SHORTEN_URL, options,
function( error, head, body )
{
if(!error && body.data.url )
shareUrl = body.data.url;
console.log(shareUrl);
}
);
@leejsinclair
Copy link
Author

Uses request module (https://github.com/mikeal/request), although i probably doesn't need to but request is so easy to use :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment