Created
April 1, 2012 04:52
-
-
Save bnchdrff/2271515 to your computer and use it in GitHub Desktop.
#detroitfuture gleaner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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