Permalink
Browse files

Add search(), minor documentation updates.

  • Loading branch information...
jdub committed Dec 24, 2010
1 parent 3612f7c commit 9bf5b25b1976016a864312e423c20bd0fe80a3c6
Showing with 30 additions and 7 deletions.
  1. +10 −4 README.md
  2. +20 −3 lib/twitter.js
View
@@ -1,7 +1,7 @@
Asynchronous Twitter client API for node.js
===========================================
-`node-twitter` aims to provide a complete, asynchronous client library for Twitter (and other compliant endpoints), including REST, stream and search APIs. It was inspired by, and uses some code from, technoweenie's `twitter-node`.
+[node-twitter](https://github.com/jdub/node-twitter) aims to provide a complete, asynchronous client library for Twitter (and other compliant endpoints), including REST, stream and search APIs. It was inspired by, and uses some code from, technoweenie's [twitter-node](https://github.com/technoweenie/twitter-node).
## Requirements
@@ -12,7 +12,7 @@ You can install node-twitter and its dependencies with npm: `npm install twitter
## Getting started
-It's early days for `node-twitter`, so I'm going to assume a fair amount of knowledge for the moment. Better documentation to come as we head towards a stable release.
+It's early days for node-twitter, so I'm going to assume a fair amount of knowledge for the moment. Better documentation to come as we head towards a stable release.
### Setup API (stable)
@@ -48,6 +48,12 @@ Note that all functions may be chained:
}
);
+### Search API (unstable, may change)
+
+ twit.search('nodejs OR #node', function(data) {
+ sys.puts(sys.inspect(data));
+ });
+
### Streaming API (stable)
The stream() callback receives a Stream-like EventEmitter:
@@ -58,7 +64,7 @@ The stream() callback receives a Stream-like EventEmitter:
});
});
-`node-twitter` also supports user and site streams:
+node-twitter also supports user and site streams:
twit.stream('user', {track:'nodejs'}, function(stream) {
stream.on('data', function (data) {
@@ -71,7 +77,7 @@ The stream() callback receives a Stream-like EventEmitter:
## Contributors
- [Jeff Waugh](http://github.com/jdub) (author)
-- [rick](http://github.com/technoweenie) (parser.js and, of course, `twitter-node`!)
+- [rick](http://github.com/technoweenie) (parser.js and, of course, twitter-node!)
## TODO
View
@@ -67,7 +67,10 @@ Twitter.prototype.get = function(url, params, callback) {
params = null;
}
- this.oauth.get(this.options.rest_base + url,
+ if (url.charAt(0) == '/')
+ url = this.options.rest_base + url;
+
+ this.oauth.get(url,
this.options.access_token_key,
this.options.access_token_secret,
function(error, data, response) {
@@ -104,7 +107,10 @@ Twitter.prototype.post = function(url, content, content_type, callback) {
content_type = null;
}
- this.oauth.post(this.options.rest_base + url,
+ if (url.charAt(0) == '/')
+ url = this.options.rest_base + url;
+
+ this.oauth.post(url,
this.options.access_token_key,
this.options.access_token_secret,
content, content_type,
@@ -129,6 +135,17 @@ Twitter.prototype.post = function(url, content, content_type, callback) {
}
+/*
+ * SEARCH (not API stable!)
+ */
+Twitter.prototype.search = function(q, params, callback) {
+ var url = this.options.search_base
+ + '/search.json?' + querystring.stringify({q:q});
+ this.get(url, params, callback);
+ return this;
+}
+
+
/*
* STREAM
*/
@@ -174,7 +191,7 @@ Twitter.prototype.stream = function(method, params, callback) {
/*
- * CONVENIENCE FUNCTIONS
+ * CONVENIENCE FUNCTIONS (not API stable!)
*/
// Timeline resources

0 comments on commit 9bf5b25

Please sign in to comment.