ntwitter
Advanced tools
Comparing version 0.2.8 to 0.2.9-2
@@ -102,7 +102,7 @@ var VERSION = '0.2.8', | ||
var json = JSON.parse(data); | ||
callback(null, json); | ||
} | ||
catch(err) { | ||
callback(err); | ||
return callback(err); | ||
} | ||
callback(null, json); | ||
} | ||
@@ -248,4 +248,4 @@ }); | ||
function processTweet(tweet) { | ||
if (tweet.limit) { | ||
stream.emit('limit', tweet.limit); | ||
if (tweet['limit']) { | ||
stream.emit('limit', tweet['limit']); | ||
} | ||
@@ -255,2 +255,5 @@ else if (tweet['delete']) { | ||
} | ||
else if (tweet['scrub-geo']) { | ||
stream.emit('scrub-geo', tweet['scrub-geo']); | ||
} | ||
else { | ||
@@ -1200,2 +1203,6 @@ stream.emit('data', tweet); | ||
function fetch(err, data) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
// FIXME: what if data[key] is not a list? | ||
@@ -1202,0 +1209,0 @@ if (data[key]) result = result.concat(data[key]); |
{ | ||
"name": "ntwitter", | ||
"version": "0.2.8", | ||
"version": "0.2.9-2", | ||
"description": "Asynchronous Twitter REST/stream/search client API for node.js.", | ||
@@ -5,0 +5,0 @@ "keywords": ["twitter","streaming","oauth"], |
@@ -6,4 +6,2 @@ Asynchronous Twitter client API for node.js | ||
## Version 0.2.8 | ||
## Installation | ||
@@ -20,6 +18,6 @@ | ||
function (err, result) { | ||
if (err) {return callback(err)} | ||
// Do something with 'result' here | ||
} | ||
function (err, result) { | ||
if (err) {return callback(err)} | ||
// Do something with 'result' here | ||
} | ||
@@ -32,10 +30,10 @@ Where `callback` is the parent function's callback. (Or any other function you want to call on error.) | ||
var twitter = require('ntwitter'); | ||
var twitter = require('ntwitter'); | ||
var twit = new twitter({ | ||
consumer_key: 'Twitter', | ||
consumer_secret: 'API', | ||
access_token_key: 'keys', | ||
access_token_secret: 'go here' | ||
}); | ||
var twit = new twitter({ | ||
consumer_key: 'Twitter', | ||
consumer_secret: 'API', | ||
access_token_key: 'keys', | ||
access_token_secret: 'go here' | ||
}); | ||
@@ -45,19 +43,26 @@ | ||
Interaction with other parts of Twitter is accomplished through their RESTful API. | ||
The best documentation for this exists at [dev.twitter.com](http://dev.twitter.com). Convenience methods exist | ||
for many of the available methods, but some may be more up-to-date than others. | ||
If your Twitter interaction is very important, double-check the parameters in the code with | ||
Twitter's current documentation. | ||
Note that all functions may be chained: | ||
twit | ||
.verifyCredentials(function (err, data) { | ||
console.log(console.dir(data)); | ||
}) | ||
.updateStatus('Test tweet from ntwitter/' + twitter.VERSION, | ||
function (err, data) { | ||
console.log(console.dir(data)); | ||
} | ||
); | ||
twit | ||
.verifyCredentials(function (err, data) { | ||
console.log(console.dir(data)); | ||
}) | ||
.updateStatus('Test tweet from ntwitter/' + twitter.VERSION, | ||
function (err, data) { | ||
console.log(console.dir(data)); | ||
} | ||
); | ||
### Search API | ||
twit.search('nodejs OR #node', function(err, data) { | ||
console.log(console.dir(data)); | ||
}); | ||
twit.search('nodejs OR #node', function(err, data) { | ||
console.log(console.dir(data)); | ||
}); | ||
@@ -70,25 +75,25 @@ ### Streaming API | ||
twit.stream('statuses/sample', function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
}); | ||
twit.stream('statuses/sample', function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
}); | ||
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) ): | ||
twit.stream('statuses/filter', {'locations':'-122.75,36.8,-121.75,37.8,-74,40,-73,41'}, function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
}); | ||
twit.stream('statuses/filter', {'locations':'-122.75,36.8,-121.75,37.8,-74,40,-73,41'}, function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(data); | ||
}); | ||
}); | ||
ntwitter also supports user and site streams: | ||
twit.stream('user', {track:'nodejs'}, function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(console.dir(data)); | ||
}); | ||
// Disconnect stream after five seconds | ||
setTimeout(stream.destroy, 5000); | ||
}); | ||
twit.stream('user', {track:'nodejs'}, function(stream) { | ||
stream.on('data', function (data) { | ||
console.log(console.dir(data)); | ||
}); | ||
// Disconnect stream after five seconds | ||
setTimeout(stream.destroy, 5000); | ||
}); | ||
@@ -100,3 +105,8 @@ ## Contributors | ||
- [rick](http://github.com/technoweenie) (parser.js and, of course, twitter-node!) | ||
And many, many more. | ||
- [Cole Gillespie](http://github.com/coleGillespie) (additional documentation) | ||
- [Tim Cameron Ryan](http://github.com/timcameronryan) | ||
- [Jonathan Griggs](https://github.com/boatmeme) | ||
- [pwagener](https://github.com/pwagener) | ||
- [fatshotty](https://github.com/fatshotty) | ||
- [Ian Babrou](https://github.com/bobrik) | ||
@@ -103,0 +113,0 @@ If you contribute and would like to see your name here, please add it with your changes! |
42667
9
1084
114