Sahil
Sahil

Reputation: 1983

Tracking a tweeter hashtag (keyword) with stream API

I am trying to track all tweets by given hashtag or keyword. The problem is I can stream the tweets when I use a simple keyword like 'animal' but when I change it to say 'animal4666' then it doesn't work. No reply is received. I am using the code below.

    twit.stream('statuses/filter', { track: 'animal4666' }, function(stream) {
        stream.on('data', function(data) {
            console.log(util.inspect(data));
        });
    });

I have made two tweets from different account like following:

'#animal4666 a'

'#animal4666 trying to find out what is going on?'

Above tweets are successfully retrieved using search API but because of the rate limitations on search API I need to use stream API so that i can check for new tweets every two seconds with node.js

The addon I am using of node.js: https://github.com/jdub/node-twitter

Can someone please help?

Upvotes: 3

Views: 4294

Answers (1)

alfonsodev
alfonsodev

Reputation: 2754

If you look the code of the library you are using, it seems that there is nothing potentially wrong
it only has a workaround when you pass an array in the track param, but is not the case

// Workaround for node-oauth vs. twitter commas-in-params bug
if ( params && params.track && Array.isArray(params.track) ) {
    params.track = params.track.join(',')
 }

So looking in to the official api docs for track method, I see two caveats that may are relevant.

Each phrase must be between 1 and 60 bytes, inclusive.

I think yours are shorter but is something to take in mind

And what I think is your real problem:

Exact matching of phrases (equivalent to quoted phrases in most search engines) is not supported.

Punctuation and special characters will be considered part of the term they are adjacent to. In this sense, "hello." is a different track term than "hello". However, matches will ignore punctuation present in the Tweet. So "hello" will match both "hello world" and "my brother says hello." Note that punctuation is not considered to be part of a #hashtag or @mention, so a track term containing punctuation will not match either #hashtags or @mentions.

You can check online your tweet text to see if it match here

Upvotes: 1

Related Questions