我正在尝试编写一个 Twilio 脚本来进行无轨语音广播 - 我希望能够直接从我的终端运行该脚本。
我有一个非常简单的脚本,直接来自twilio-rb
gem 文档:
# This should be in an initializer or similar
Twilio::Config.setup \
:account_sid => account,
:auth_token => token
Twilio::Call.create :to => '+1234567890', :from => '+0987654321',
:url => xml_file
xml_file
是我本地机器上的一个 xml 文件,但它会引发此错误:
Error #21205: Url is not a valid url
如何编写上述脚本来操作本地 xml 文件?最终目标是严格地拨打电话、播放音频消息、收集按钮按下并根据收到的号码执行操作。Twiml XML 文件应该为我做这件事,如果我能让它工作的话。
编辑:
使用保管箱共享链接时,我在 Twilio 界面中收到此错误:
'Twilio is unable to process the Content-Type of the provided URL. Please see the Twilio Markup XML Documentation for more information on valid Content-Types.
You must return a Content-Type for all requests. Requests without a Content-Type will appear in the Debugger as a 502 Bad Gateway error.
Having a phone number, outgoing call request or action attribute refer to a non XML or audio resource.
Having a Play verb attempt to play non-audio content, such as XML or text.
Verify that that your web server is returning a Content-Type and it is the expected value
Make sure the URL noted refers to a valid resource'
为了确保,我复制了一个我知道可以在我的 XML 文件中使用的示例:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="man">Hey man! Listen to this!</Say>
<Play>http://foo.com/cowbell.mp3</Play>
<Say voice="man">What did you think of that?!</Say>
<Record action="http://foo.com/handleRecording.php" method="GET" maxLength="20" finishOnKey="*"/>
<Gather action="/process_gather.php" method="GET">
<Say>Now hit some buttons!</Say>
</Gather>
<Say voice="man">Awesome! Thanks!</Say>
<Hangup/>
</Response>