desmondmorris / node-twitter

Client library for the Twitter REST and Streaming API's.
https://www.npmjs.com/package/twitter
MIT License
1.27k stars 237 forks source link

"client.stream" gets old tweets. #348

Closed K-Rintaro closed 3 years ago

K-Rintaro commented 3 years ago

Using "client.stream", node-twitter gets old tweets every five minutes when Twitter user doesn't tweet. It seems that node-twitter gets older and older tweet as time goes on.

Source code:

client.stream('statuses/filter', {follow : 'TWITTER_USER_ID'}, function(stream) {
  stream.on('data', function(data) {
      var text = data.text;
      console.log(text) 
  });
});
K-Rintaro commented 3 years ago

I found the cause of the problem. "created_at" (the time that the tweet was created) is wrong.

Source code:

client.stream('statuses/filter', {follow : 'TWITTER_USER_ID'}, function(stream) {
    stream.on('data', function(data) {
      console.log(data.created_at)
    });
});

Result:

Sun Jan 10 11:51:18 +0000 2021
Sun Jan 10 11:51:50 +0000 2021
Sun Jan 10 11:51:57 +0000 2021

Remember that the Twitter user did't tweet while this code was running.