Skip to content

Instantly share code, notes, and snippets.

@Hillsie
Created December 31, 2018 08:55
Show Gist options
  • Save Hillsie/dcf94b9d5bf5914236f60a3ba005d6ca to your computer and use it in GitHub Desktop.
Save Hillsie/dcf94b9d5bf5914236f60a3ba005d6ca to your computer and use it in GitHub Desktop.
Basic OAuth sign in to Twitter and get tweet collection defined in tweetdeck
// OAuth handles the nounce and tokens for you under the hood, but seems like OAuth is nolonger being maintained.
// Works as of 31 Dec 2018, unless I added a typo while obfusicating secrets... think not.
const OAuth = require('oauth').OAuth;
const oauth = new OAuth(
'https://api.twitter.com/oauth/request_token',
'https://api.twitter.com/oauth/access_token',
'your application consumer key',
'your application secret',
'1.0A',
null,
'HMAC-SHA1'
);
//Go to tweetdeck, define your collection, find the url. Starts with custom-xxxxxxxx. Belows number is fake.
oauth.get(
'https://api.twitter.com/1.1/collections/entries.json?id=custom-1070128872635056735',
'your user token for this app', //test user token
'your user secret for this app', //test user secret
function (e, response){
if (e){
console.error(e);
} else {
let tweetObject = JSON.parse(response);
console.log(JSON.stringify(tweetObject, 0, 2);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment