Skip to content

Instantly share code, notes, and snippets.

@jonathanhculver
Created August 16, 2013 00:04
Show Gist options
  • Select an option

  • Save jonathanhculver/6246097 to your computer and use it in GitHub Desktop.

Select an option

Save jonathanhculver/6246097 to your computer and use it in GitHub Desktop.
Send text messages to an array of phone numbers
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