twilio php 顺序拨号逻辑
我正在为 twilio in PHP 编写一个应用程序,我需要一些逻辑方面的帮助或什么我可以做……我有点陷入你可以说的逻辑过程中。
我想知道 Twilio 中是否有一个功能或任何功能可以让您跟踪在一个会话中拨打了多少次电话。我正在制作一个顺序拨号应用程序,如果我可以跟踪呼叫失败或占线的次数,则可以用来呼叫下一个号码。一种可能性是使用计数器...
类似于 $R++ 之类的东西
,位于操作 URL 代码的开头,因此每次执行该操作 url 时,它都会添加 1,这会告诉您调用失败了多少次,但这也带来了问题是每次操作 url 运行时,它都会将变量 $R 作为新值或 0 启动,因此不会存储 $R,这会阻止我们得知进行了多少次调用。
我当前的代码是:
<?php
require "twilio.php";
// initiate response library
$response = new Response();
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$PhoneNumbers= array('4167641543','6478604858');
?>
<Response>
<Say voice="woman">Calling the first person</Say>
<Dial action="handle-key.php" method="POST" timeout="15"> <?php echo $PhoneNumbers[0] ?> </Dial>
</Response>
----------------------------------handle-key.php-------------------- ----------------
<?php
require "twilio.php";
// initiate response library
$response = new Response();
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$PhoneNumbers= array('4167641543','6478604858');
if(($_REQUEST['DialStatus'] == "busy" || $_REQUEST['DialCallStatus'] == "no-answer" || $_REQUEST['DialCallStatus'] == "failed" || $_REQUEST['DialCallStatus'] == "canceled")) {
$variableToCall=$PhoneNumbers[1];
}
$R++;
?>
<Response>
<Say voice="woman">Calling the first person</Say>
<Dial action="handle-key.php" method="POST" timeout="15"> <?php echo $PhoneNumbers[1] ?> </Dial>
<Say voice="woman"> <?php $R=0; ?> </Say>
</Response>
I am writing an application for twilio in PHP and I need some help with the logic or what I can do..I am somewhat stuck in the logic process you could say.
I was wondering if there is a function in Twilio or any feature that allows you to keep track of how many times you have made calls in one session. I am making a Sequential Dialling application and if I can keep track of how many times a call was failed to be picked up or was busy then that can be used to call the next number. A possibility is to use a counter...
something like
$R++ at the beginning of the action URL code so each time that action url is executed it adds 1 which tells you how many times a call has failed but the problem with that as well is that each time the action url runs it starts the variable $R as a new value or as 0 and so the $R isn't stored which prevents us from telling how many calls were made.
My Current code is:
<?php
require "twilio.php";
// initiate response library
$response = new Response();
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$PhoneNumbers= array('4167641543','6478604858');
?>
<Response>
<Say voice="woman">Calling the first person</Say>
<Dial action="handle-key.php" method="POST" timeout="15"> <?php echo $PhoneNumbers[0] ?> </Dial>
</Response>
----------------------handle-key.php----------------------------------
<?php
require "twilio.php";
// initiate response library
$response = new Response();
header("content-type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
$PhoneNumbers= array('4167641543','6478604858');
if(($_REQUEST['DialStatus'] == "busy" || $_REQUEST['DialCallStatus'] == "no-answer" || $_REQUEST['DialCallStatus'] == "failed" || $_REQUEST['DialCallStatus'] == "canceled")) {
$variableToCall=$PhoneNumbers[1];
}
$R++;
?>
<Response>
<Say voice="woman">Calling the first person</Say>
<Dial action="handle-key.php" method="POST" timeout="15"> <?php echo $PhoneNumbers[1] ?> </Dial>
<Say voice="woman"> <?php $R=0; ?> </Say>
</Response>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以增加一个(例如 MySQL)数据库值,而不是增加 $R...
如果您需要在整个调用中保持该值持久,那么您可以将该值与调用的 cookie 相关联。
凯尔在 GetSatisfaction 中提到:
如果您需要在用户的生命周期内保持该值不变,那么您可以将该值与呼叫者的电话号码相关联。
Rather than increment $R, you could increment a (MySQL, for example) database value...
If you need to keep that value persistent for an entire call, then you could associate the value with the call's cookie.
Kyle mentioned over in GetSatisfaction:
If you need to keep that value persistent for the life of a user, then you could associate the value with the caller's phone number.