Skip to content

Instantly share code, notes, and snippets.

@bnchdrff
Created April 1, 2012 04:52
Show Gist options
  • Save bnchdrff/2271515 to your computer and use it in GitHub Desktop.
Save bnchdrff/2271515 to your computer and use it in GitHub Desktop.
#detroitfuture gleaner
// packages.json:
{
"name": "twitglean",
"version": "0.0.1",
"dependencies": {
"felix-couchdb": "1.0.3"//,
// add as git repo in node_modules/ntwitter: "https://github.com/horixon/ntwitter.git",
// add as git repo in node_modules/immortal-ntwitter: "https://github.com/horixon/immortal-ntwitter.git"
}
}
// storage:
// create a couchdb called dfgleanings
// server.js:
// run as `node server.js`
var util = require('util'),
longtwitter = require('immortal-ntwitter'),
couchdb = require('felix-couchdb'),
client = couchdb.createClient(5984, 'localhost'),
db = client.db('dfgleanings');
var twit = new longtwitter({
consumer_key: 'xxx',
consumer_secret: 'yyy',
access_token_key: 'zzz',
access_token_secret: 'ååå'
});
twit.immortalStream('statuses/filter', {track:['#detroitfuture','#amc12','#amc2012']}, function(stream) {
stream.on('data', function(data) {
util.log('got tweet ' + data.id_str);
db.saveDoc(data.id_str, data, function(er, ok) {
if (er) throw new Error(JSON.stringify(er));
util.puts('saved tweet ' + data.id_str);
});
});
stream.on('error', function(error) {
util.log('error:');
console.log(util.inspect(error));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment