姜戈 | twilio 发送短信
我使用 twilio 作为移动验证机制,我之前没有使用 twilio 的经验,但是查看示例 PHP 代码,我在代码中使用了这个,但显然它给了我一个 400 Bad request
HTTP 错误。代码如下:
d = {
'TO' : '*** *** ****',
'FROM' : '415-555-1212',
'BODY' : 'Hello user, please verify your device using this code %s' % verNumber
}
try:
print account.request('/%s/Accounts/%s/SMS/Messages' % \
(API_VERSION, ACCOUNT_SID), 'POST', d)
except Exception, e:
return HttpResponse('Error %s' % e)
verNumber
是随机生成的,并且接收者的号码在 twilio 中进行验证。
我跟踪异常,发现这个错误
Error 400 The source 'From' phone number is required to send an SMS
,这是什么意思?
谢谢。
I'm using twilio as for a mobile verification mechanism, I have no prior experience in using twilio but looking at the sample PHP code I used this one in my code but apparently it's giving me an 400 Bad request
HTTP error. Here's the code:
d = {
'TO' : '*** *** ****',
'FROM' : '415-555-1212',
'BODY' : 'Hello user, please verify your device using this code %s' % verNumber
}
try:
print account.request('/%s/Accounts/%s/SMS/Messages' % \
(API_VERSION, ACCOUNT_SID), 'POST', d)
except Exception, e:
return HttpResponse('Error %s' % e)
verNumber
is randomly generated and the receiver's number is validated in twilio.
I follow the exception and found this error
Error 400 The source 'From' phone number is required to send an SMS
What does this mean.?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 python 库中的 一些 twilio 示例,我注意到包含有效负载的字典是输入混合大小写,而您使用的是大写字母。
该错误可能非常直接,而不是
尝试
SMS 快速入门(在文档中)支持这个想法。
希望这有帮助。
Looking at some of the twilio examples from the python libraries I notice that the dictionaries containing the payload are typed in MixedCase whereas you've used UPPERCASE.
The error might be quite straight forward rather than
try
The SMS Quickstart ( in the documentation) supports this idea.
Hope this helps.
尝试 http://bitbucket.org/vgavro/django-smsgate/ ,您可能需要为 twilio 编写后端 - 但剩下的已经为你完成了。
Try http://bitbucket.org/vgavro/django-smsgate/ , you may need to write backend for twilio - but the rest is done for you already.