Created
October 30, 2009 02:51
-
-
Save thoughtless/222070 to your computer and use it in GitHub Desktop.
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
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