I use the following code to retrieve in real time the tweets with a particuliar hashtag:
var util = require('util'),
twitter = require('twitter');
var twit = new twitter({
consumer_key: CONSUMER_KEY,
consumer_secret: CONSUMER_SECRET,
access_token_key: ACCESS_TOKEN_KEY,
access_token_secret: ACCESS_TOKEN_SECRET
});
twit.stream('statuses/filter', {'track': ['#MYHASHTAG']}, function(stream) {
stream.on('data', function(data) {
console.log(util.inspect(data));
});
stream.on('error', function(err){
console.log(err.message);
});
});
I created a couple of tweets with this particular tag but they are not taken into account. The only output I have before the script exit is:
{ disconnect:
{ code: 7,
stream_name: 'User-statuses77671',
reason: 'admin logout' } }
Any idea why they do not appear in the stream ?
Also, I would expect the above code to run continuously but it stop right away.
Note: I tried the same stuff with ruby (and tweetstream) and I have the same results.
Try this syntax instead:
var stream = twit.stream('statuses/filter', {'track': ['#MYHASHTAG']});
stream.on('tweet', function (tweet) {
console.log(tweet);
})