ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.32k stars 573 forks source link

Stream 'user' ignores 'with' #457

Open ilyador opened 5 years ago

ilyador commented 5 years ago

Using const stream = T.stream('user', { with: 'myhandle' }) still brings me all the stream of people I follow instead of the user (myself, in that case).

super-ienien commented 5 years ago

User stream are being deprecated by twitter they will be removed from their API soon : https://twittercommunity.com/t/details-and-what-to-expect-from-the-api-deprecations-this-week-on-august-16-2018/110746

They are replaced by the Account Activity API, you should switch to it quickly.

ilyador commented 5 years ago

Does Twit have an API account activity? I also tried using const stream = T.stream('statuses/filter', { follow: user }) and got 406

maziyarpanahi commented 5 years ago

In your second post you are using stream not user activity (retired): https://developer.twitter.com/en/docs/accounts-and-users/subscribe-account-activity/api-reference/user-stream

Pay attention to the endpoint: https://userstream.twitter.com/1.1/user.json

In streaming to follow you need UserID, not username. The stream is not retired, will be but in future.

The bottom two are retired (23rd of August entirely):

The streaming endpoint to hit. One of:

ilyador commented 5 years ago

So does Twit has an API for the Account Activity API?

super-ienien commented 5 years ago

no

tracycollins commented 5 years ago

I'm still not clear on what works now, what will be retired, and what will work for the foreseeable future.

So, will this endpoint continue to be supported by Twitter and twit?

T.stream('statuses/filter', {'track': [], 'follow': []})

If so, occasionally an error occurs that's not being handled by twit. I believe I'm handling all of the events twit provides, but this error slips through occasionally and crashes my app:

events.js:167 throw er; // Unhandled 'error' event ^ Error: Bad Twitter streaming request: 401 at Object.exports.makeTwitError (/node_modules/twit/lib/helpers.js:74:13) at Request. (/node_modules/twit/lib/streaming-api-connection.js:96:29) at Request.emit (events.js:187:15) at IncomingMessage. (/node_modules/request/request.js:1083:12) at Object.onceWrapper (events.js:273:13) at IncomingMessage.emit (events.js:187:15) at endReadableNT (_stream_readable.js:1092:12) at process._tickCallback (internal/process/next_tick.js:63:19) Emitted 'error' event at: at Request. (/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)