使用看似正确的XML时Twilio Twiml 12100错误
我目前正在尝试使用Twilio Python库来启动传出电话,在说消息时通过键盘或语音等待用户输入,然后通过回调将其返回到我在其他地方运行的PHP脚本,但是即使看似看似在我的twiml中使用的好XML,当用户键入键盘上的键时,我似乎会遇到应用错误,我在下面包含了所有详细信息。
代码:
call = client.calls.create(
status_callback='https://endpoint.example/myphpscript.php',
status_callback_method='POST',
twiml='<?xml version="1.0" encoding="UTF-8"?><Response><Gather action="https://endpoint.example/myphpscript.php" method="POST"><Say>This is a test message, please work</Say></Gather></Response>',
to=destnumber,
from_=twilionumber
)
执行时,它会按预期进行呼叫,并开始读取由&lt; say&gt;的消息,但是当用户键入其键盘上的键时,它说:“我们很抱歉有一个应用程序错误。 “
在我的Twilio呼叫日志中查看我可以看到Twiml的Twiml,由Twilio收到和使用 “&lt;?xml版本= \” 1.0 \“ encoding = \” utf-8 \“?&gt;&gt;&gt; wesponse&gt;&gt;&gt;&gt; cather Action = \“ https://ws.chainsaw.rip/testwilio。 php \“ method = \” post \“&gt; say&gt;这是一条测试消息,请工作&lt;/say&gt;&lt;/
capent Twilio控制台如下所示
Msg ""
parserMessage "Error on line 2 of document : Premature end of file. "
ErrorCode "12100"
url "https://endpoint.example/myphpscript.php"
LogLevel "ERROR"
。
I'm currently trying to use the twilio python library to start an outgoing call, wait for user input through the keypad or speech while saying a message and then return it through a callback to a php script I have running elsewhere, however even with seemingly good XML used in my twiml, I seem to get an application error when the user hits a key on their keypad, I've included all the details I can below.
Code:
call = client.calls.create(
status_callback='https://endpoint.example/myphpscript.php',
status_callback_method='POST',
twiml='<?xml version="1.0" encoding="UTF-8"?><Response><Gather action="https://endpoint.example/myphpscript.php" method="POST"><Say>This is a test message, please work</Say></Gather></Response>',
to=destnumber,
from_=twilionumber
)
When this executes it makes the call as expected, and starts to read off the message as defined by <say>, however when the user hits a key on their keypad it says "We're sorry there was an application error."
Looking in my Twilio call logs I can see the twiml recieved and used by twilio which is below"<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Gather action=\"https://ws.chainsaw.rip/testwilio.php\" method=\"POST\"><Say>This is a test message, please work</Say></Gather></Response>"
The error information as seen in the twilio console is shown below
Msg ""
parserMessage "Error on line 2 of document : Premature end of file. "
ErrorCode "12100"
url "https://endpoint.example/myphpscript.php"
LogLevel "ERROR"
I am pretty new to twilio so any and all help or suggestions would be greatly appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您用什么来生成twiml?
删除
\
s后,我将twiml粘贴在验证器中,并且有效。\
在之前“
”使您的twiml无效。也许尝试使用twiml bin作为twiml的终点,看看它是否有效。您的语言或TWIML发电机生成TWIML指令。
What are you using to generate your TWIML?
I pasted the twiml in the validator after removing
\
s and it worked.\
after before the"
is making your TWIML invalid.Maybe try using the TWIML bin as the endpoint for the TWIML and see if it works. You should preferably use helper libraries in your language or twiml generators to generate the twiml instructions.