Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// define libraries you would need
var oauth = require('oauth')
// define your OAuth-application credentials
var twitterConsumerKey = 'xxxxxxxxxxxxxxxxxxxx'
var twitterConsumerSecret = 'xxxxxxxxxxxxxxxxxxxx'
var api = new oauth.OAuth(
'https://twitter.com/oauth/request_token',
'https://twitter.com/oauth/access_token',
twitterConsumerKey,
twitterConsumerSecret,
'1.0A',
'',
'HMAC-SHA1'
)
// use the token information received after getting the access (!) token
var user = {
oauthToken: 'xxxxxxxxxxxxxxxxxxxx',
oauthSecret: 'xxxxxxxxxxxxxxxxxxxx'
}
// use starting point to only get new entries
var lastItem = '&since_id=12890371837123173' // id is of course dynamic and from a DB entry
api.get(
'https://api.twitter.com/1.1/statuses/home_timeline.json?count=20' + lastItem,
user.authToken,
user.authSecret,
function (error, items, response) {
if (error) {
console.log('Timeline error')
context.fail(JSON.stringify(error, null, 2))
} else {
var list = JSON.parse(items)
context.succeed({items:list})
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment