【问题标题】:Dialpad for extension calling - Twilio用于分机呼叫的拨号盘 - Twilio
【发布时间】:2016-12-05 10:04:39
【问题描述】:

如何在 Twilio 中实现拨号盘功能?我正在从浏览器向引用此 link 的电话号码拨打电话。

TwiML 代码:

<?php
header('Content-type: text/xml');

// put a phone number you've verified with Twilio to use as a caller ID number
$callerId = '+1xxxxxxxxx';

// put your default Twilio Client name here, for when a phone number isn't given
$number   = 'Name';

// get the phone number from the page request parameters, if given
if (isset($_REQUEST['PhoneNumber'])) {
    $number = htmlspecialchars($_REQUEST['PhoneNumber']);
}

// wrap the phone number or client name in the appropriate TwiML verb
// by checking if the number given has only digits and format symbols
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
    $numberOrClient = "<Number>" . $number . "</Number>";
} else {
    $numberOrClient = "<Client>" . $number . "</Client>";
}
?>
<Response>
    <Dial callerId="<?php echo $callerId ?>">
          <?php echo $numberOrClient ?>
    </Dial>
</Response>

如何在我的页面中添加拨号盘,以便用户能够输入扩展或菜单选项?示例:点击 1 连接到销售经理。

如果有人知道这件事,请帮助我。提前致谢。

【问题讨论】:

    标签: php twilio twilio-api


    【解决方案1】:

    Twilio 布道者在这里。

    查看 Twilio Client for JavaScript SDK 中的 sendDigits 函数。调用此函数告诉 SDK 播放 DTMF 音。

    function senddigits() {
      if (connection!=null) {
          connection.sendDigits("1");
      }
    }
    

    希望对您有所帮助。

    【讨论】:

      【解决方案2】:

      这是 Javascript SDK(Twilio 客户端)的完整动态代码的样子。

       Twilio.Device.connect(function(connection) {
      
                //play DTMF tones
              if(connection!==null){
              $(document).on('click' ,'.numpad', function () {
              var number = $(this).val();
                  connection.sendDigits(number);
              });
              }
      });
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-05-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多