How to get user twitter stream using node.js twit?

I am using the node.js Twit module; after the user is authenticated, how do I get these user tweets? The documentation does not explain how to do this.

The following returns null:

var Twit=require('twit'); var T = new Twit({ consumer_key: nconf.get('twitterAuth:consumerKey') , consumer_secret: nconf.get('twitterAuth:consumerSecret') , access_token: user.token , access_token_secret: user.tokenSecret }); var username=user.profile.username; T.get('search/tweets', {screen_name: username, count:100 }, function(err, data, response) { //q: 'banana since:2011-11-11', count: 100 res.send(data); }) 

Thanks for any help - there must be something obvious. (I confirmed that the code works).

+5
source share
2 answers

You probably already solved your problem, but for someone else who is struggling with this, here is my solution:

 var Twit = require('twit'); var T = new Twit({ consumer_key: '' , consumer_secret: '' , access_token: '' , access_token_secret: '' }) var options = { screen_name: 'sandagolcea', count: 3 }; T.get('statuses/user_timeline', options , function(err, data) { for (var i = 0; i < data.length ; i++) { console.log(data[i].text); } }) 

This shows my last 3 tweets :) Hooray!

+11
source

Source: https://habr.com/ru/post/1205246/


All Articles