Skip to content

Instantly share code, notes, and snippets.

@awaxa
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awaxa/6e5203c83f0daa353608 to your computer and use it in GitHub Desktop.
Save awaxa/6e5203c83f0daa353608 to your computer and use it in GitHub Desktop.

stream twitter messages through iron mq

setup

git clone https://gist.github.com/6e5203c83f0daa353608 twitter-iron
cd twitter-iron
bundle install

listen

export IRON_TOKEN=my_token IRON_PROJECT_ID=my_project_id
bundle exec ruby poll.rb

post

export IRON_TOKEN=my_token IRON_PROJECT_ID=my_project_id
export TWITTER_CONSUMER_KEY=my_consumer_key TWITTER_CONSUMER_SECRET=my_consumer_secret TWITTER_ACCESS_TOKEN=my_access_token TWITTER_ACCESS_TOKEN_SECRET=my_access_token_secret
bundle exec ruby push.rb
source 'https://rubygems.org'
gem 'iron_mq', '~> 5.0.1'
gem 'twitter', '~> 5.11.0'
GEM
remote: https://rubygems.org/
specs:
addressable (2.3.6)
buftok (0.2.0)
equalizer (0.0.9)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
http (0.6.2)
http_parser.rb (~> 0.6.0)
http_parser.rb (0.6.0)
iron_core (1.0.5)
rest (>= 2.6.4)
iron_mq (5.0.1)
iron_core (>= 0.5.1)
json (1.8.1)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
multipart-post (2.0.0)
naught (1.0.0)
net-http-persistent (2.9.4)
netrc (0.7.7)
rest (2.7.2)
net-http-persistent (>= 2.9.1)
rest_client (>= 1.7.1)
rest_client (1.7.3)
netrc (~> 0.7.7)
simple_oauth (0.2.0)
thread_safe (0.3.4)
twitter (5.11.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.9)
faraday (~> 0.9.0)
http (~> 0.6.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.2.0)
PLATFORMS
ruby
DEPENDENCIES
iron_mq (~> 5.0.1)
twitter (~> 5.11.0)
require 'iron_mq'
ironmq = IronMQ::Client.new
queue = ironmq.queue("my_queue")
queue.poll { |msg| puts msg.body }
require 'iron_mq'
require 'twitter'
config = {
:consumer_key => ENV['TWITTER_CONSUMER_KEY'],
:consumer_secret => ENV['TWITTER_CONSUMER_SECRET'],
:access_token => ENV['TWITTER_ACCESS_TOKEN'],
:access_token_secret => ENV['TWITTER_ACCESS_TOKEN_SECRET'],
}
ironmq = IronMQ::Client.new
queue = ironmq.queue("my_queue")
client = Twitter::Streaming::Client.new(config)
client.filter(:locations => '-122.75,36.8,-121.75,37.8') do |tweet|
puts queue.post(tweet.text).inspect if tweet.is_a?(Twitter::Tweet)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment