有条件的短信响应与Django / Twilio [英] Conditional SMS response with Django/Twilio

查看:148
本文介绍了有条件的短信响应与Django / Twilio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在根据不同的参数(来电显示,文本正文)调整短信响应,并且错误是HTTP检索失败
我已经尝试使用Flask教程为不同的调用者:

I'm trying to adjust the SMS response depending on different parameters (caller id, body of text) and the error is "HTTP retrieval failure" I've tried using the Flask tutorial for different callers:

def hello_monkey():
    """Respond and greet the caller by name."""

    from_number = request.values.get('From', None)
    if from_number in callers:
        message = callers[from_number] + ", thanks for the message!"
    else:
        message = "Monkey, thanks for the message!"

但是我知道Django可能会有所不同,所以我已经尝试了这些和其他几个: p>

But I realize Django might be different, so I've tried these and a couple others:

def hello_monkey(request, From)
    #with    
    from = From

def hello_monkey(request):
    #with
    number = request.POST["Body"]

感谢
编辑:忘记了链接

推荐答案

实际上在Django它将是非常相似的,你应该阅读更多关于请求。由于您不知道请求是POST还是GET,您可以使用 HttpRequest.REQUEST

Actually in Django it would be quite similar, you should read more about the request. Since you don't know if the request is POST or GET, you can take in use of HttpRequest.REQUEST:

callers = {
    "+14158675309": "Curious George",
    "+14158675310": "Boots",
    "+14158675311": "Virgil",
}

def hello_monkey(request):
    """Respond and greet the caller by name."""

    from_number = request.REQUEST.get('From', None)
    if from_number in callers:
        message = callers[from_number] + ", thanks for the message!"
    else:
        message = "Monkey, thanks for the message!"

    # .... your code ....

希望它帮助!

这篇关于有条件的短信响应与Django / Twilio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆