twilio php 顺序拨号逻辑

发布于 2024-11-16 20:39:22 字数 1896 浏览 0 评论 0原文

我正在为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

和我恋爱吧 2024-11-23 20:39:22

您可以增加一个(例如 MySQL)数据库值,而不是增加 $R...

如果您需要在整个调用中保持该值持久,那么您可以将该值与调用的 cookie 相关联。

凯尔在 GetSatisfaction 中提到:

拨打电话时,Twilio 将每个呼叫视为一个新会话。
Cookie 将在通话期间持续存在;然而,一旦
调用结束,cookies将被处理。

如果您需要在用户的生命周期内保持该值不变,那么您可以将该值与呼叫者的电话号码相关联。

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:

When making phone calls, Twilio treats each call as a new session.
Cookies will persist for the duration of the call; however, once the
call is finished, cookies will be disposed.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文