AvianFlu / ntwitter

Asynchronous Twitter REST/stream/search client API for node.js
https://github.com/AvianFlu/ntwitter
Other
784 stars 163 forks source link

“follow” options does not work in streaming. twitter returns 406 Not Acceptable #107

Open goker-dev opened 11 years ago

goker-dev commented 11 years ago

I try to use follow options in stream function but twitter retuns 406 Not Acceptable Returned by the Search API when an invalid format is specified in the request.

MY USAGE:

twit.stream('statuses/filter', { 'follow':'gokercebeci' }, 
function(stream) {
    stream.on('data',function(data){
      console.log(data);
    });
});

A Related Question: http://stackoverflow.com/questions/15652361/can-not-use-follow-in-the-streaming-api-in-ntwitter-recieving-unspecified-er

joedyndale commented 11 years ago

I'm using 'follow' and it works just fine for me. You have to use the userId (the number) of the user, and not the username when specifying who to follow. This can be retrieved with a different API call, or from a site like http://mytwitterid.com/ if you just need a few predefined users.

UPDATE: OK, I see an answer stating the same thing has been posted on that StackOverflow qurestion - but might as well keep this here as well.

siwalikm commented 7 years ago

You have to use the userID not the userName. I was doing the same mistake for quite sometime but not it works perfectly. code =>

var   Twit = require('twit');

var T = new Twit({
  consumer_key:         config.key.consumer_key,
  consumer_secret:      config.key.consumer_secret,
  access_token:         config.key.access_token,
  access_token_secret:  config.key.access_token_secret
});

var stream = T.stream('statuses/filter', { follow: 4708084272 })
stream.on('tweet', function (tweet) {
  console.log(tweet)
})