-
-
Save jdg/429095 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/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