我想拨打我的 Twilio 号码,该号码立即挂断,然后给我回电。这与我之前的问题相似(但不完全相同)。
问题在于迫使 Twilio 挂断电话。
红宝石代码是:
get '/callback' do
to = params['From']
from = 'my Twilio number'
"<Response><Hangup/></Response>"
sleep 5
# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new account_sid, auth_token
@call = @client.account.calls.create(
:from => from, # From your Twilio number
:to => to, # To any number
# Fetch instructions from this URL when the call connects
:url => 'https://dl.dropboxusercontent.com/u/85088004/twilio/twilio.xml'
)
end
这会产生一条消息:“我们很抱歉,但发生了系统错误”。问题在于挂断指令。我已经尝试过如上所述
<Response><Hangup/></Response> #without enclosing double or single quotes
和
Twilio::TwiML::Response.new do |r|
r.Hangup
end.text
两者都不会产生预期的挂断结果。
怎么了?
提前谢谢了!