Skip to content

Instantly share code, notes, and snippets.

@thoughtless
Created October 30, 2009 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoughtless/222070 to your computer and use it in GitHub Desktop.
Save thoughtless/222070 to your computer and use it in GitHub Desktop.
def test_heroku_post
# Ignore postback for completed call
return render(:nothing => true) if params[:CallStatus] == 'completed'
method = params[:method] || 'POST' # change this to test
# Twilio posting digits
if params[:Digits]
twilio = Twilio::Verb.new do |verb|
verb.say params[:Digits]
verb.hangup
end
render :text => twilio.response
# Initial Twilio to see what it should do.
elsif params[:CallStatus]
twilio = Twilio::Verb.new do |verb|
verb.gather(:method => method) do
verb.say "Enter some digits followed by pound."
end
end
render :text => twilio.response
# Human telling us who to call
elsif params[:call]
Twilio.connect(APP_CONFIG['twilio']['sid'], APP_CONFIG['twilio']['auth_token'])
call = Twilio::Call.make(
APP_CONFIG['twilio']['phone_out'],
params[:call],
url_for(:method => method),
:Method => method)
render :text => call.inspect
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment