最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get user's twitter stream using node.js twit? - Stack Overflow

programmeradmin1浏览0评论

I'm using the node.js Twit module; after the user has authenticated, how do I get that user's tweets? The documentation does not explain how to do it.

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 - must be something obvious. (I have confirmed the code works).

I'm using the node.js Twit module; after the user has authenticated, how do I get that user's tweets? The documentation does not explain how to do it.

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 - must be something obvious. (I have confirmed the code works).

Share Improve this question edited Oct 22, 2014 at 4:47 metalaureate asked Oct 22, 2014 at 2:47 metalaureatemetalaureate 7,73211 gold badges59 silver badges97 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 19

You've probably already solved your problem, but for anyone else out there that's 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 :) Cheers!

I needed statuses/user_timeline

https://dev.twitter.com/rest/reference/get/statuses/user_timeline

发布评论

评论列表(0)

  1. 暂无评论