nodejs twit how do you follow a users LIVE twitter stream

0 votes

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

May 30, 2022 in Node-js by Neha
• 9,020 points
953 views

1 answer to this question.

0 votes

In the following argument, you must use the numeric user ID rather than the screen name. The users/show endpoint can be used to get the user ID for a specific screen name.

To know more about Node JS, It's recommended to join Node JS Course today.

answered May 30, 2022 by Vaani
• 7,070 points

Related Questions In Node-js

0 votes
1 answer

How do you log content of a JSON object in Node.js?

Hello @kartik, Try this one: console.log("Session: %j", session); If the ...READ MORE

answered Jul 16, 2020 in Node-js by Niroj
• 82,840 points
876 views
0 votes
1 answer

How do you run a js file using npm scripts?

Hello @kartik, Try this: { "scripts" : { ...READ MORE

answered Oct 12, 2020 in Node-js by Niroj
• 82,840 points
11,316 views
0 votes
1 answer

How do I “include” functions from my other files in nodejs?

Hello @kartik, You require any js file,so you just ...READ MORE

answered Jul 9, 2020 in Node-js by Niroj
• 82,840 points
3,424 views
0 votes
1 answer

How do you reinstall an app's dependencies using npm?

Hello @kartik, The easiest way is  to delete node_modules folder ...READ MORE

answered Jul 12, 2020 in Node-js by Niroj
• 82,840 points
2,628 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,428 views
0 votes
1 answer

Extending a middy middleware function in nodejs

Your pseudocode comes close to being correct. ...READ MORE

answered May 30, 2022 in Node-js by Vaani
• 7,070 points
1,059 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP