node.jstwitter-searchnode-twitter

Node: Twitter search api request issue


I am observing the wrong output while hitting Twitter search api and i am using this npm module.

I am passing since, from, until parameters to the api, but i am not getting any tweet where as generating the cURL request from the Twitter's oauth signature generator tool gives the correct response. https://dev.twitter.com/oauth/tools/signature-generator

var TWITTER_SEARCH = 'search/tweets';
twitter.get(TWITTER_SEARCH, { q: criteria }, function (err, result, response) {
        console.log(err);
        console.log('Got %d tweets', result.statuses.length);
        return cb(err, result, response);
    })

I have supplied criteria in following ways"

I always get 0 tweets whereas there exists tweets between these dates ( I am getting tweets through cURL request via Postman tool).

Received Response

{ statuses: [],
  search_metadata: 
   { completed_in: 0.02,
     max_id: 755754337922641900,
     max_id_str: '755754337922641920',
     query: 'from%253AJeffMcMahon_Chi%2520since%253A2016-07-17%2520until%253A2016-07-20%2520',
     refresh_url: '?since_id=755754337922641920&q=from%253AJeffMcMahon_Chi%2520since%253A2016-07-17%2520until%253A2016-07-20%2520&include_entities=1',
     count: 15,
     since_id: 0,
     since_id_str: '0' } }

Am i passing parameter in wrong format ? What should be the right format ?


Solution

  • Removing the URI encoding from the criteria resolves the issue for me.

    Now Criteria looks like

    from:my_screen_name since:2016-07-14 until:2016-07-18