Last active
December 18, 2015 21:29
-
-
Save leejsinclair/5847445 to your computer and use it in GitHub Desktop.
Quick script that uses bit.ly OAuth api access tokens
This file contains hidden or 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
| 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); | |
| } | |
| ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uses request module (https://github.com/mikeal/request), although i probably doesn't need to but request is so easy to use :)