Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Twilio-传入语音Webhook在同一个呼叫中被呼叫两次?_Python 3.x_Twilio_Azure Functions - Fatal编程技术网

Python 3.x Twilio-传入语音Webhook在同一个呼叫中被呼叫两次?

Python 3.x Twilio-传入语音Webhook在同一个呼叫中被呼叫两次?,python-3.x,twilio,azure-functions,Python 3.x,Twilio,Azure Functions,试图理解为什么传入的语音呼叫webhook会被呼叫两次 我正在使用带有HTTP触发器的Azure函数。Python 3 当我通过web浏览器测试TwiML并查看日志时,它会返回一次有效的TwiML <?xml version="1.0" encoding="UTF-8"?><Response><Say>hello this is a test </Say><Play digits="wwww#" /></Response>

试图理解为什么传入的语音呼叫webhook会被呼叫两次

我正在使用带有HTTP触发器的Azure函数。Python 3

当我通过web浏览器测试TwiML并查看日志时,它会返回一次有效的TwiML

<?xml version="1.0" encoding="UTF-8"?><Response><Say>hello this is a test </Say><Play digits="wwww#" /></Response>

谢谢艾伦帮我解决这个问题

我需要添加值为“text/xml”的标题内容类型

将参数mimetype='text/xml'添加到func.HttpResponse()中


我可以解释的另一个链接,有时基于会话发起协议(SIP)响应,运营商可能会重试呼叫,认为原始运营商无法终止呼叫。新的CallSID就是本例的线索。繁忙(486响应代码)并不常见,但情况似乎就是这样。我无法解释为什么你的webhook会被调用两次。如果您在调用日志中查找CallSID,那么Azure函数中的TwiML是什么?您是否配置了故障转移URL,该URL正在启动?嗨@Alan,查看呼叫日志时,有两个不同的CallSid都返回最后一个SIP响应603拒绝我从上面的帖子中看到了相同的TwiML,而且我还没有配置故障转移URL。@Alan知道TwiML bin中的代码为什么成功,azure函数为什么会导致错误吗?将请求的图片添加到原始postMy建议中。如果要使用Postman()之类的工具并比较内容类型和HTTP响应代码(这里很可能),那么这两者之间肯定存在差异。您将无法使用TwiML Bin执行此操作(因为它会检查特定的签名头-X-Twilio-signature),但请改用此URL,然后将其与Azure functions端点响应进行比较。@Alan感谢您的建议!!我没有将内容类型设置为text/xml。它现在正常工作了很好!谢谢你的更新和张贴方式,你解决它!
import logging
from twilio.twiml.voice_response import Say, Play, VoiceResponse
import azure.functions as func


def main(req: func.HttpRequest) -> func.HttpResponse:
    response = VoiceResponse()
    response.say('hello this is test bots')
    response.play('', digits='wwww#')

    return func.HttpResponse(str(response), status_code=200)
import logging
from twilio.twiml.voice_response import Say, Play, VoiceResponse
import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:
    response = VoiceResponse()
    response.say('hello this is test bots')
    response.play('', digits='wwww#')

    return func.HttpResponse(str(response), status_code=200, mimetype='text/xml')