呼叫和连接

时间:2016-06-28 09:13:13

标签: twilio

我试图同时打电话给两个人并想加入电话。例如,呼叫A和B,一旦其中一个拿起说A,我想播放一条消息并在这种情况下连接另一个人B.所以A和B通信twilio正在拨打电话并连接它们。这可能吗?

1 个答案:

答案 0 :(得分:0)

假设我们使用PHP进行此实现,它看起来就像这样。

致电A的代码:

    <?php
    // Get the PHP helper library from twilio.com/docs/php/install
    require_once('/path/to/twilio-php/Services/Twilio.php'); // Loads the library

    // Your Account Sid and Auth Token from twilio.com/user/account
    $sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; 
    $token = "your_auth_token"; 
    $client = new Services_Twilio($sid, $token);
    $person_a_phone = "+15555555555";
    $verified_twilio_number = "+14444444444";
    $person_b_phone = "+13333333333";
    $call = $client->account->calls->create($verified_twilio_number, $person_a_phone, "http://callback.php?person_b_phone=$person_b_phone", array());

代码呼叫人B(即callback.php):

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
        <Play>http://url-to-play-your-message.com</Play>
        <Dial timeout="10" record="true"><?php echo $_REQUEST['person_b_phone'] ?></Dial>
    </Response>

参考文献: https://www.twilio.com/docs/api/rest/making-calls