Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 130 lines (91 sloc) 4.091 kB
a9fcb53 @AvianFlu Update README.md
authored
1 # DEPRECATED
2
3 This repository has been unmaintained for two years, is deprecated on `npm`, and should not be considered an authoritative source of anything. Sorry for the inconvenience.
4
83e8246 @jdub The big shift from twitter-node to node-twitter.
jdub authored
5 Asynchronous Twitter client API for node.js
6 ===========================================
606bec1 @technoweenie handle chunked json
technoweenie authored
7
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
8 [ntwitter](http://github.com/AvianFlu/ntwitter) is an improved version of jdub's [node-twitter](http://github.com/jdub/node-twitter), which in turn was inspired by, and uses some code from, technoweenie's [twitter-node](http://github.com/technoweenie/twitter-node).
9
606bec1 @technoweenie handle chunked json
technoweenie authored
10
b243b47 @AvianFlu [docs] Updated docs.
authored
11 ## Installation
12
13 You can install ntwitter and its dependencies with npm: `npm install ntwitter`.
3612f7c @jdub minor documentation tweaks
jdub authored
14
606bec1 @technoweenie handle chunked json
technoweenie authored
15
83e8246 @jdub The big shift from twitter-node to node-twitter.
jdub authored
16 ## Getting started
ec889a7 @tim-smart Installation notes update - added NPM support
tim-smart authored
17
33350f7 @AvianFlu [docs] Updated docs
authored
18 This library is, for the most part, the same API as `node-twitter`. Much of the documentation below is straight from `node-twitter` - credit goes to [jdub](http://github.com/jdub) for putting all this together in the first place.
19
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
20 The most significant API change involves error handling in callbacks. Callbacks now receive the error as a separate parameter, rather than as part of the data. This is consistent with node's standard library. Callbacks should now look something like this:
21
22 ``` javascript
23 function (err, result) {
24 if (err) return callback(err);
33350f7 @AvianFlu [docs] Updated docs
authored
25
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
26 // Do something with 'result' here
27 }
28 ```
33350f7 @AvianFlu [docs] Updated docs
authored
29
01d560f @AvianFlu [docs] Fixes to docs.
authored
30 Where `callback` is the parent function's callback. (Or any other function you want to call on error.)
ec889a7 @tim-smart Installation notes update - added NPM support
tim-smart authored
31
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
32
fe18793 @AvianFlu [docs] More readme fixes.
authored
33 ### Setup API
606bec1 @technoweenie handle chunked json
technoweenie authored
34
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
35 The keys listed below can be obtained from [dev.twitter.com](http://dev.twitter.com) after [setting up a new App](https://dev.twitter.com/apps/new).
f432f29 @AvianFlu [docs] Added to docs.
authored
36
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
37 ``` javascript
38 var twitter = require('ntwitter');
f97dfe4 @AvianFlu [docs] Updated docs.
authored
39
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
40 var twit = new twitter({
41 consumer_key: 'Twitter',
42 consumer_secret: 'API',
43 access_token_key: 'keys',
44 access_token_secret: 'go here'
45 });
46 ```
606bec1 @technoweenie handle chunked json
technoweenie authored
47
ddc6b81 @jdub README: GET/POST functions, streaming notes
jdub authored
48
fe18793 @AvianFlu [docs] More readme fixes.
authored
49 ### REST API
606bec1 @technoweenie handle chunked json
technoweenie authored
50
5fbdac3 @AvianFlu [docs] Added to documentation.
authored
51 Interaction with other parts of Twitter is accomplished through their RESTful API.
52 The best documentation for this exists at [dev.twitter.com](http://dev.twitter.com). Convenience methods exist
53 for many of the available methods, but some may be more up-to-date than others.
54 If your Twitter interaction is very important, double-check the parameters in the code with
55 Twitter's current documentation.
56
ddc6b81 @jdub README: GET/POST functions, streaming notes
jdub authored
57 Note that all functions may be chained:
606bec1 @technoweenie handle chunked json
technoweenie authored
58
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
59 ``` javascript
60 twit
61 .verifyCredentials(function (err, data) {
62 console.log(data);
63 })
64 .updateStatus('Test tweet from ntwitter/' + twitter.VERSION,
65 function (err, data) {
66 console.log(data);
67 }
68 );
69 ```
606bec1 @technoweenie handle chunked json
technoweenie authored
70
fe18793 @AvianFlu [docs] More readme fixes.
authored
71 ### Search API
9bf5b25 @jdub Add search(), minor documentation updates.
jdub authored
72
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
73 ``` javascript
74 twit.search('nodejs OR #node', {}, function(err, data) {
75 console.log(data);
76 });
77 ```
9bf5b25 @jdub Add search(), minor documentation updates.
jdub authored
78
fe18793 @AvianFlu [docs] More readme fixes.
authored
79 ### Streaming API
606bec1 @technoweenie handle chunked json
technoweenie authored
80
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
81 The stream() callback receives a Stream-like EventEmitter.
ddc6b81 @jdub README: GET/POST functions, streaming notes
jdub authored
82
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
83 Here is an example of how to call the `statuses/sample` method:
80a3666 added docs for filter
cole authored
84
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
85 ``` javascript
86 twit.stream('statuses/sample', function(stream) {
87 stream.on('data', function (data) {
88 console.log(data);
89 });
90 });
91 ```
5fbdac3 @AvianFlu [docs] Added to documentation.
authored
92
7380f47 added docs for filter
cole authored
93 Here is an example of how to call the 'statuses/filter' method with a bounding box over San Fransisco and New York City ( see streaming api for more details on [locations](https://dev.twitter.com/docs/streaming-api/methods#locations) ):
80a3666 added docs for filter
cole authored
94
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
95 ``` javascript
96 twit.stream('statuses/filter', {'locations':'-122.75,36.8,-121.75,37.8,-74,40,-73,41'}, function(stream) {
97 stream.on('data', function (data) {
98 console.log(data);
99 });
100 });
101 ```
4d9520f @jdub README updates
jdub authored
102
b243b47 @AvianFlu [docs] Updated docs.
authored
103 ntwitter also supports user and site streams:
4d9520f @jdub README updates
jdub authored
104
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
105 ``` javascript
106 twit.stream('user', {track:'nodejs'}, function(stream) {
107 stream.on('data', function (data) {
108 console.log(data);
109 });
110 stream.on('end', function (response) {
111 // Handle a disconnection
112 });
113 stream.on('destroy', function (response) {
114 // Handle a 'silent' disconnection from Twitter, no end/error event fired
115 });
116 // Disconnect stream after five seconds
117 setTimeout(stream.destroy, 5000);
118 });
119 ```
606bec1 @technoweenie handle chunked json
technoweenie authored
120
83e8246 @jdub The big shift from twitter-node to node-twitter.
jdub authored
121 ## Contributors
f87fe03 @technoweenie link to twitter docs in the readme
technoweenie authored
122
78bd918 @benatkin reformat and make small changes to wording in README
benatkin authored
123 [Lots of people contribute to this project. You should too!](https://github.com/AvianFlu/ntwitter/contributors)
4d9520f @jdub README updates
jdub authored
124
125 ## TODO
126
127 - Complete the convenience functions, preferably generated
c3fb7a5 @martindale Update master
martindale authored
128 - Support [recommended reconnection behaviour](https://dev.twitter.com/docs/streaming-apis/connecting#Best_practices) for the streaming APIs
b243b47 @AvianFlu [docs] Updated docs.
authored
129
Something went wrong with that request. Please try again.