Created
August 16, 2013 00:04
-
-
Save jonathanhculver/6246097 to your computer and use it in GitHub Desktop.
Send text messages to an array of phone numbers
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
| toArray = [] | |
| $smsToken = '' | |
| $phoneNumber = '' | |
| get '/text' do | |
| toArray.each do |element| | |
| callSmsScript("Hi", element) | |
| sleep(5) | |
| end | |
| end | |
| #call the tropo API to send the message | |
| def callSmsScript(inputText, inputPhoneNumber) | |
| result = Net::HTTP.get(URI.parse('http://api.tropo.com/1.0/sessions?action=create&token='+$smsToken+'&inputPhoneNumber='+inputPhoneNumber+'&inputText='+inputText+'')) | |
| return result | |
| end | |
| post '/sms.json' do | |
| t = Tropo::Generator.new | |
| v = Tropo::Generator.parse request.env["rack.input"].read | |
| #get values from url | |
| to = v[:session][:parameters][:input_phone_number] | |
| msg = "Time for the NxJU!" | |
| t.call(:to => to, :from => $phoneNumber, :network => "SMS", :channel => 'TEXT') | |
| t.say(:value => msg) | |
| t.response | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment