I'm using twit (https://www.npmjs.com/package/twit) to stream live tweets from particular twitter users.
I have the following code:
var stream = T.stream('statuses/filter', { follow: ['nodejs'] })
stream.on('tweet', function (tweet) {
console.log(tweet.text)
})
However, it generates the following error:
Error: Bad Twitter streaming request: 406
at Object.exports.makeTwitError (/Users/simoncarr/dev/node/nodeletetweet/scripts/get_mp_data/node_modules/twit/lib/helpers.js:74:13)
at Request.<anonymous> (/Users/simoncarr/dev/node/nodeletetweet/scripts/get_mp_data/node_modules/twit/lib/streaming-api-connection.js:96:29)
at Request.emit (events.js:187:15)
at Gunzip.<anonymous> (/Users/simoncarr/dev/node/nodeletetweet/scripts/get_mp_data/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:273:13)
at Gunzip.emit (events.js:187:15)
at endReadableNT (_stream_readable.js:1094:12)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Request.<anonymous> (/Users/simoncarr/dev/node/nodeletetweet/scripts/get_mp_data/node_modules/twit/lib/streaming-api-connection.js:99:14)
at Request.emit (events.js:187:15)
[... lines matching original stack trace ...]
at process._tickCallback (internal/process/next_tick.js:63:19)
Simply tracking terms in a tweet will suffice; for example, the following code will suffice.
var stream = T.stream('statuses/filter', { track: ['apples'] })
stream.on('tweet', function (tweet) {
console.log(tweet.text)
})
According to Twitter's guidelines, I should be able to just replace track with follow.
https://developer.twitter.com/en/docs/tweets/filter-realtime/api-reference/post-statuses-filter.html