我设置了一个页面“example.com/firstsms”以通过 Twilio 发送短信并重定向到主页。如果我然后使用电话回复消息,我想回复确认。截至目前,没有任何反应。
在 urls.py 中我有:
(r'^hellomonkey/$', 'crusher.views.HelloMonkey'),
在 views.py 中我试图调整他们的 Flask example :
def HelloMonkey(request):
"""Respond to incoming calls with a simple text message."""
resp = twilio.twiml.Response()
resp.sms("Hello, Mobile Monkey")
return HttpResponseRedirect(str(resp), content_type="text/plain")
绞尽脑汁!谢谢
最佳答案
你正在返回一个 HttpResponseRedirect
所以它会尝试重定向到某个页面,当然它不起作用。您应该改用 HttpResponse
:
from django.http import HttpResponse
def HelloMonkey(request):
"""Respond to incoming calls with a simple text message."""
resp = twilio.twiml.Response()
resp.sms("Hello, Mobile Monkey")
return HttpResponse(str(resp))
关于python - 如何用Django/Twilio回复短信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17982019/