'use strict';
Convenience method for searches.
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);
var Search;
module.exports = Search = (function() {
uri
- base URI’s to use (this should be provided by the library itself)opts
- Object
with the user-provided paramsconsumer_key
- requiredconsumer_secret
- requiredtoken
- requiredtoken_secret
- requiredAn Object
with the method query
.
function Search(uri, opts) {
this.uri = uri;
this.opts = opts;
var tt = require('twitter-rest-lite');
this.api = tt.API(this.opts);
}
params
- Object with params:q
: [Required]callback
- Callback Functionvar q = {
q: 'term for the search'
};
search.query(q, callback);
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;
})();