0

我正在将 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
4

1 回答 1

0

OP在上面的评论中解决了:

弄清楚了。连接的路由需要是 POST 并且我还必须将 skip_before_action :verify_authenticity_token 添加到twilio 控制器,因为它位于会员门后面。

于 2016-08-04T23:22:27.610 回答