Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require 'rubygems'
- require 'tweetstream'
- require 'boxcar_api'
- SETTINGS = {
- :key => 'xyz', # Provider Key
- :secret => 'xyz', # Provider Secret
- :tweeter => 'macrumorslive' # Whom we'll be following on Twitter
- :tweeter_id => 1581511, # The tweeter's user id (check their RSS feed)
- :twitter_user => 'xyz', # The username for your Twitter account.
- :twitter_pass => 'xyz' # The password for your Twitter account.
- }
- class ServerTrack
- def deliver_push_notification(status)
- # Streaming Follow API gives us RTs, in_reply_to's etc. We just want original tweets from the tweeters account.
- if status[:user][:screen_name].downcase == SETTINGS[:tweeter].downcase
- bp = BoxcarAPI::Provider.new(SETTINGS[:key], SETTINGS[:secret])
- bp.broadcast(status[:text])
- $stderr.puts "*** Sent notification for #{status[:text]}"
- end
- end
- def run
- $stderr.puts "Starting tweet provider for #{SETTINGS[:tweeter]}"
- TweetStream::Client.new(SETTINGS[:twitter_user], SETTINGS[:twitter_pass]).follow(SETTINGS[:tweeter_id]) do |status|
- deliver_push_notification(status)
- end
- end
- end
- st = ServerTrack.new
- st.run
Add Comment
Please, Sign In to add comment