'use strict';

Module: Search

Convenience method for searches.

Methods

Usage

var TwitterLib = require('twitter-rest');
var search = new TwitterLib.Search(var_with_config);

var params = {
  q: 'term I\'m searching for'
};

search.query(params, callback);

Code

var Search;

module.exports = Search = (function() {

Constructor

Parameters

Returns

An Object with the method query.

Code

  function Search(uri, opts) {
    this.uri = uri;
    this.opts = opts;

    var tt = require('twitter-rest-lite');

    this.api = tt.API(this.opts);
  }

Public: do a tweets query

Parameters

Example

var q = {
  q: 'term for the search'
};

search.query(q, callback);

Code

  Search.prototype.query = function(params, callback) {
    var self = this;

    if (params.q == null) {
      return callback(new Error(
        'Twitter:Search.query() requires q to be defined in the params'
      ));
    }

    self.api.get('/search/tweets.json', params, callback);
  };

  return Search;
})();
h