Permalink
Browse files

add search API IF as follows:

  client.search(query, option, callback);

See API specification at https://dev.twitter.com/docs/api/1/get/search.

This commit is the final commit for 0.1.1 release.
  • Loading branch information...
1 parent 22b4df0 commit 06a937bb6e022d75df069bc9e5a2094b4096b7fe @yssk22 committed Sep 27, 2011
Showing with 24 additions and 1 deletion.
  1. +23 −0 lib/twitter/index.js
  2. +1 −1 package.json
View
@@ -8,6 +8,7 @@ var util = require('util'),
url = require('url'),
crypto = require('crypto'),
http = require('http'),
+ querystring = require('querystring'),
EventEmitter = require('events').EventEmitter;
var OAuth = require('oauth').OAuth;
var normalizeError = require('../util').normalizeError;
@@ -80,6 +81,28 @@ exports.createClient = function(consumerKey, consumerSecret, options){
addModule('timeline');
addModule('list');
addModule('stream');
+
+ // search API IF
+ client.search = function(query, options, callback){
+ if( typeof(options) == 'function' ){
+ callback = options;
+ options = {};
+ }
+ options.q = query;
+ http.get({
+ host: 'search.twitter.com',
+ path: '/search.json?' + querystring.stringify(options)
+ }, function(res){
+ var data = '';
+ res.on('data', function(chunk){
+ data += chunk;
+ });
+ res.on('end', function(){
+ var handler = createResponseHandler(callback);
+ handler(null, data, res);
+ });
+ });
+ };
return client;
}
View
@@ -1,6 +1,6 @@
{
"name": "twbot",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "Twitter bot microframework using node.js",
"tags" : ["twitter", "bot"],
"author" : "Yohei Sasaki <yssk22@gmail.com>",

0 comments on commit 06a937b

Please sign in to comment.