Twilio REST API HTTP 400 错误:“SendDigits 的长度必须小于 32 个字符" [英] Twilio REST API HTTP 400 error: "SendDigits must be less than 32 characters long"
问题描述
我的一个应用程序一年多来一直在调用 Twilio REST API,没有出现任何问题.上周,我一直收到此错误:
One of my apps has been making Twilio REST API calls for more than a year without problems. For the last week, I consistently get this error now:
HTTP 400 错误:{"message": "SendDigits 必须少于 32 个字符长", "status": 400}
HTTP 400 error: {"message": "SendDigits must be less than 32 characters long", "status": 400}
我的请求看起来像这样(一些信息已编辑):(method='POST', uri='https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxxx/Calls.json', **kwargs={'auth': ('xxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxx'), 'data': {'From': '+1415DDDDDDD', 'SendDigits': 'ww0w1234w16w6w415DDDDDDDD#w415DDDDDDDD#', '收件人': '+1415DDDDDD', 'Url': 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'}, 'headers': {'Accept': 'application/json', 'Accept-Charset': 'utf-8', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'twilio-python/3.6.13 (Python2.7.6)'}})
My request looks like this (some information redacted): (method='POST', uri='https://api.twilio.com/2010-04-01/Accounts/xxxxxxxxxxxxxxxxxx/Calls.json', **kwargs={'auth': ('xxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxx'), 'data': {'From': '+1415DDDDDDD', 'SendDigits': 'ww0w1234w16w6w415DDDDDDD#w415DDDDDDD#', 'To': '+1415DDDDDDD', 'Url': 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'}, 'headers': {'Accept': 'application/json', 'Accept-Charset': 'utf-8', 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'twilio-python/3.6.13 (Python 2.7.6)'}})
就好像 SendDigits 的最大长度最近发生了变化,尽管我在任何地方都找不到相关文档.
It's as if the maximum length of SendDigits was recently changed, although I can't find documentation of this anywhere.
我该如何解决这个问题?更改 SendDigits 的值对我来说并不是一个真正的选择.
How can I get around this? Changing the value of the SendDigits isn't really an option for me.
推荐答案
来自 Twilio 的 Megan 在这里.
Megan from Twilio here.
感谢您的反馈,对于您遇到的麻烦,我深表歉意.
Thank you for your feedback, I'm sorry for the trouble you are experiencing.
有一个解决方法,在 TwiML 中使用 <Playdigits="">
而不是将其作为 POST 参数传递,这也应该能够达到等效的结果.有关使用
的示例,请查看:
There is a workaround, to use <Play digits="">
in TwiML instead of passing it as a POST param, this should also be able to reach an equivalent result. For examples using <Play>
, check out:
https://www.twilio.com/docs/api/twiml/play#attributes-digits
Python 中的示例(使用上面的字符串)看起来像:
And an example in Python (using your string from above) would look something like:
def play_digits():
r = twiml.Response()
r.play(digits="ww0w1234w16w6w415DDDDDDD#w415DDDDDDD#")
return str(r)
如果您觉得这有用,请告诉我.
Please let me know if you find this to be useful.
这篇关于Twilio REST API HTTP 400 错误:“SendDigits 的长度必须小于 32 个字符"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!