-
-
Save leereilly/3831359 to your computer and use it in GitHub Desktop.
Automated Twillio RubyConf ticket avaliability checker
This file contains 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
require 'mechanize' | |
require 'twilio-ruby' | |
# Need to save a file with the html body to refer to later in the script since this is run | |
# in a cron job. | |
if File.exists?("rubyregistration.html") | |
body = File.read("rubyregistration.html") | |
else | |
File.open("rubyregistration.html","w+") do |file| | |
file.puts Mechanize.new.get("https://rubyconf2012.busyconf.com/bookings/new").search("/html/body/div/div/div/div[2]").inner_html | |
end | |
body = File.read("rubyregistration.html") | |
end | |
account_sid = 'YOUR ACCOUNT SID' | |
auth_token = 'AUTH TOKEN' | |
current_body = Mechanize.new.get("https://rubyconf2012.busyconf.com/bookings/new").search("/html/body/div/div/div/div[2]").inner_html | |
if current_body != body | |
@client = Twilio::REST::Client.new account_sid, auth_token | |
@client.account.sms.messages.create( | |
:from => 'FROM_NUM', | |
:to => 'CALL_NUM', | |
:body => 'RubyConf Tickets are ready right now!!!!!' | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment