Skip to content

Instantly share code, notes, and snippets.

@evanderkoogh
Created October 19, 2014 06:36
Show Gist options
  • Save evanderkoogh/2ae2904aff498e050061 to your computer and use it in GitHub Desktop.
Save evanderkoogh/2ae2904aff498e050061 to your computer and use it in GitHub Desktop.
Store a realtime stream of Twitter search in Redis DB
redis = require('redis').createClient process.env['REDIS_PORT_6379_TCP_PORT'], process.env['REDIS_PORT_6379_TCP_ADDR']
redis.select 1
Twitter = require 'twitter'
credentials =
consumer_key: process.env.TWITTER_CONSUMER_KEY
consumer_secret: process.env.TWITTER_CONSUMER_SECRET
access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY
access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET
twitter = new Twitter credentials
keywords = 'Whatever'
twitter.stream 'statuses/filter', {track: keywords}, (stream) ->
stream.on 'data', (data) ->
unless data.retweeted_status
console.log "#{data.user.screen_name} (#{data.user.followers_count}): #{data.text}"
redis.lpush 'to_test', "User: #{data.user.screen_name} (#{data.user.followers_count}): #{data.text}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment