gpt4 book ai didi

php - Twilio 客户端 DTMF 不工作

转载 作者:搜寻专家 更新时间:2023-10-31 21:14:50 27 4
gpt4 key购买 nike

我正在开发 Twilio 客户端应用程序,但我很难发送 DTMF 音调。这是我到目前为止的代码:

<script type="text/javascript">
$.each(['0','1','2','3','4','5','6','7','8','9','star','pound'], function(index, value) {
$('#button' + value).click(function(){
if(connection) {
if (value=='star')
connection.sendDigits('*')
else if (value=='pound')
connection.sendDigits('#')
else
connection.sendDigits(value)
return false;
}
});
});
</script>


<div id="dialpad">
<table>
<tr>
<td><input type="button" value="1" id="button1"></td>
<td><input type="button" value="2" id="button2"></td>
<td><input type="button" value="3" id="button3"></td>
</tr>
<tr>
<td><input type="button" value="4" id="button4"></td>
<td><input type="button" value="5" id="button5"></td>
<td><input type="button" value="6" id="button6"></td>
</tr>
<tr>
<td><input type="button" value="7" id="button7"></td>
<td><input type="button" value="8" id="button8"></td>
<td><input type="button" value="9" id="button9"></td>
</tr>
<tr>
<td><input type="button" value="*" id="buttonstar"></td>
<td><input type="button" value="0" id="button0"></td>
<td><input type="button" value="#" id="buttonpound"></td>
</tr>
</table>
</div>

当我调用我的测试号码并按下拨号盘上的按钮时,它没有发送值。非常感谢您对此提供任何帮助?

最佳答案

在您的脚本 block 中,您需要有可用的连接对象。所以在你的功能之上,你需要像这样的东西:

var connection = null;
Twilio.Device.setup('your token');
params = { "number" : "5559871234", "outbound" : "true" };
connection = Twilio.Device.connect(params);

本质上,这个函数只需要“看到”连接变量。如果您的 javascript 文件位于不同的位置并且您无法合并它们,您可以将连接对象设置为全局(不理想)至少看看您是否可以让它工作。

connection = null;

(前面没有“var”)

关于php - Twilio 客户端 DTMF 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11285740/

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