2

自从我升级到:

gem 'twilio-ruby', '~> 5.0.0.rc4'

调用成功设置为 Twilio,但出现了一些错误

app/controllers/home_controller.rb:59:in `rescue in call'

require "rubygems"
require "twilio-ruby"

def call
  @twilio = Twilio::REST::Client.new account_sid, auth_token

  begin
    @call = @twilio.account.calls.create({
     :to => , 
      :from => twilio_number,
      :url => url,
      :method => "GET",
      :if_machine => "Hangup",
      :timeout => "20"
    })

    # Getting current call status (seems like error here...!)
    get_status(@call.sid)

  rescue Twilio::REST::RequestError => error
    @err_msg = error.message
    puts @err_msg
    #returned error is like below:
    #NameError (uninitialized constant Twilio::REST::RequestError)
  end
end

获取当前通话状态的代码:

def get_status(sid)
  @twilio = Twilio::REST::Client.new account_sid, auth_token
  @call = @twilio.account.calls.get(sid)
  puts "Process Status : " + @call.status
  return @call.status
end

请帮忙弄清楚。

谢谢!

4

1 回答 1

0

对于版本 5,请尝试Twilio::REST::RestError.

这记录在这里

有新的类可以从中挽救错误。新库现在使用 Twilio::REST::RestError 类。

于 2018-05-31T07:17:44.483 回答