Skip to content

Instantly share code, notes, and snippets.

@boxcar
Created June 7, 2010 19:23
Show Gist options
  • Save boxcar/429056 to your computer and use it in GitHub Desktop.
Save boxcar/429056 to your computer and use it in GitHub Desktop.
#!/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment