gpt4 book ai didi

python - 为什么当我通过浏览器调用时 twilios 调用转移不起作用,但在调用具有完全相同请求 url 的 twilio 号码时工作正常

转载 作者:行者123 更新时间:2023-11-28 22:39:18 25 4
gpt4 key购买 nike

我有一个带有请求 url 的电话号码(说出文本然后转接电话),但后来我有一个应用程序(浏览器出站调用)转到相同的请求 url,只有文本到语音有效,调用转接出错并挂断。为什么不像号码的请求url那样转发呢?我检查了一下,功能 token 呈现良好...

View .py

def once_connected_view(request):
response = twiml.Response()
response.say("Please wait while we connect your call.", voice='alice')
response.dial("xxx-xx-xxx-xxxx")
return HttpResponse(str(response))

def home_view(request):
capability = TwilioCapability(account_sid, auth_token)
capability.allow_client_outgoing(application_sid)
token = capability.generate()
query_set = Model.objects.all()
return render(request, "base.html", {"query_set":query_set, "token":token})

网址.py

urlpatterns = [
url(r'^$', views.home_view, name="home"),
url(r'^once_connected/', views.once_connected_view, name="once_connected"),
]

号码请求地址

http://xx.xx.com/once_connected/ http 获取

应用请求地址

http://xx.xx.com/once_connected/ http 获取

主站地址

https://xx.xx.com/

基础.html

<!doctype html>
<head>
<script type="text/javascript" src="https://static.twilio.com/libs/twiliojs/1.2/twilio.min.js"></script>
<script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=320, height=device-height, target-densitydpi=medium-dpi" />
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'cars/responsive.css' %}">
</head>
<body>
<div class="container" id="wrapper">
<div class="video-background-container">
<video preload="auto" autoplay="" loop="" muted="" class="video-background hidden-xs hidden-sm">
<source type="video/mp4" src="omitted">
</video>
</div>
<div class="grid-overlay text-center">
<nav class="navbar navbar-default navbar-fixed-top" style="background:none;">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" id="logo" href="#">Brand Name</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="replace-call"><a href="#" data-toggle="modal" data-target="#myModal">Contact Us</a></li>
</ul>
</div>
</div>
</nav>

...
<script src="https://code.jquery.com/jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script type="text/javascript">

/* Create the Client with a Capability Token */
Twilio.Device.setup("{{ token }}");

/* Let us know when the client is ready. */
Twilio.Device.ready(function (device) {
$(".replace-call").html("<a href='#' onclick='call()'>Call From Browser</a>");
});

/* Report any errors on the screen */
Twilio.Device.error(function (error) {
$(".replace-call").html('<a href="#" data-toggle="modal" data-target="#myModal">Contact Us</a>');
});

Twilio.Device.connect(function (conn) {
$(".replace-call").html("<a href='#' onclick='hangup()'>End Call</a>");
});

/* Connect to Twilio when we call this function. */
function call() {
Twilio.Device.connect();
}
function hangup() {
Twilio.Device.disconnectAll();
$(".replace-call").html('<a href="#" data-toggle="modal" data-target="#myModal">Contact Us</a>');
}
</script>
</body>
</html>

我托管在 pythonanywhere 上。

最佳答案

在脱发很少之后,我通过向拨号动词添加一个 callerID 属性使其工作。

def once_connected_view(request):
response = twiml.Response()
response.say("Please wait while we connect your call.", voice='alice')
response.dial("xxx-xx-xxx-xxxx", callerId="+xxxxxxxxxx") # here
return HttpResponse(str(response))

关于python - 为什么当我通过浏览器调用时 twilios 调用转移不起作用,但在调用具有完全相同请求 url 的 twilio 号码时工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34908401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com