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

Why does twilios call forwarding not work when I am calling through browser, but work fine when calling a twilio number with exact same request url

我有一个 phone 号码和一个请求 url 可以正常工作(说出文本然后转接呼叫)但是我有一个应用程序(浏览器出站呼叫)进行相同的操作请求 url 并且只有文本到语音有效,呼叫的转发会出错并挂断。为什么不像号码的请求url那样转发呢?我检查了一下,功能令牌呈现良好...

views.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})

urls.py

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

号码请求url

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

应用请求url

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

主站点url

https://xx.xx.com/

base.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))