Skip to content

Instantly share code, notes, and snippets.

@tcr
Created October 17, 2012 04:24
Show Gist options
  • Save tcr/3903698 to your computer and use it in GitHub Desktop.
Save tcr/3903698 to your computer and use it in GitHub Desktop.
See a streaming list of all tweets concerning the presidential debate.
// npm install rem read clarinet
var rem = require('rem');
var read = require('read');
var clarinet = require('clarinet');
// Create Twitter API, prompting for key/secret.
var tw = rem.load('twitter', 1.0).prompt();
// Authenticate user via the console.
rem.console(tw, function (err, user) {
// Pass the statuses/sample stream to a JSON parser and print only the tweets.
user.stream('statuses/filter').post({
track: ['obama', 'romney', 'debate']
}, function (err, stream) {
stream.pipe(clarinet.createStream()).on('key', function (key) {
if (key == 'text') {
this.once('value', function (tweet) {
console.log(String(tweet));
})
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment