如何在 Twilio 中执行 dialpad 功能?我正在从浏览器拨打电话到引用此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 = '+1';
// put your default Twilio 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)) {
$numberOr = "<Number>" . $number . "</Number>";
} else {
$numberOr = "<>" . $number . "</>";
}
?>
<Response>
<Dial callerId="<?php echo $callerId ?>">
<?php echo $numberOr ?>
</Dial>
</Response>
如何在我的页面中添加 dialpad,以便用户应该能够输入扩展或菜单选项?
请帮助我,如果有人知道这一点。
Twilio 传教士在这里。
查看 Twilio for JavaScript SDK 中的sendDigits
函数。调用此函数会通知 SDK 播放 DTMF 音调。
function senddigits() {
if (connection!=null) {
connection.sendDigits("1");
}
}
希望有帮助。
这是一个完整的动态代码看起来像 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);
});
}
});
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(33条)