自从我升级到:
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
请帮忙弄清楚。
谢谢!