This Twilio API Sample code isn’t working in Rails 3:
#voice_controller.rb
def reminder
@postto = BASE_URL + '/directions'
respond_to do |format|
format.xml { @postto }
end
end
#reminder.xml.builder
xml.instruct!
xml.Response do
xml.Gather(:action => @postto, :numDigits => 1) do
xml.Say "Hello this is a call from Twilio. You have an appointment
tomorrow at 9 AM."
xml.Say "Please press 1 to repeat this menu. Press 2 for directions.
Or press 3 if you are done."
end
end
Any ideas?
Twilio seems to successfully make the phone call (I can see the params with my phone number, location, etc.) but then return this vague response code:
Completed 406 Not Acceptable in 0ms
Twilio doesn’t send an Accept HTTP header in its requests, which causes Rails 3 to decide that it can’t respond with an appropriate content type. I think the following will get around that for you though:
# voice_controller.rb def reminder @postto = BASE_URL + '/directions' render :content_type => 'application/xml' end