我正在将 twilio click 集成到我的 rails 项目中。
一切正常,但是 url: 在我的 twilio 控制器中无法在 heroku 上找到。但是,如果您在浏览器中导航到它,就可以找到它。电话拨通了,但声音说“对不起,出现问题,再见。” 如果我将 url 更改为外部 xml 文件,它可以正常工作,只是无法识别这个特定的文件。所以我相信控制器等工作正常。
twillio_controller.rb
def call
@full_phone = current_user.phone
@partial_phone = @full_phone.last(-1)
@connected_number = "+61" + @partial_phone
@client = Twilio::REST::Client.new @@twilio_sid, @@twilio_token
# Connect an outbound call to the number submitted
@call = @client.calls.create(
:from => @@twilio_number,
:to => @connected_number,
:url => 'http://besttradies.herokuapp.com/mytradies/connect.xml', # Fetch instructions from this URL when the call connects
)
@msg = { :message => 'Phone call incoming!', :status => 'ok' }
end
def connect
# Our response to this request will be an XML document in the "TwiML"
# format. Our Ruby library provides a helper for generating one
# of these documents
response = Twilio::TwiML::Response.new do |r|
r.Say 'If this were a real click to call implementation, you would be connected to an agent at this point.', :voice => 'alice'
end
render text: response.text
end