Search code examples
javascriptnode.jstwittertwitter-streaming-api

how to follow statuses of a list of users using twitter streaming api in node.js with twit module


I am using twit node.js module for twitter api, I am trying to get status stream of a list of users by using their id but when i run the script it the following error

Error: Bad Twitter streaming request: 406

Following is the code

var http = require('http')
, server = http.createServer(app)
, Twit = require('twit')
server.listen(4040);

var T = new Twit({
consumer_key:           'abc'
, consumer_secret:      'abc'
, access_token:         'abc'
, access_token_secret:  'abc'
});
var watchList = ['@Kashmala_Tariq', '@Mushahid', '@Fbuttho'];
var stream = T.stream('statuses/filter', { follow : watchList });

stream.on('tweet', function (tweet) {
console.log('@'+tweet.user.screen_name + ':::' + tweet.text);
});

this is the link to the api i am using twittwit-module

please guide me what is it that i am doing wrong in this script


Solution

  • You can to use the id instead of the screen_name:

    var stream = T.stream('statuses/filter', { follow : ['123456789', '23456789'] });
    stream.on('tweet', function (tweet, err) {
        console.log(tweet);
    })
    

    Moreover, you can figure out the id by using a service like http://gettwitterid.com.