在两个未在 twilio 中注册的号码之间拨打电话

Iur*_*iro 3 twilio twilio-php twilio-api

有什么方法可以在我的两个用户之间拨打电话吗?我的意思是...我有一个带有注册号码的 twilio 帐户,我必须给我的客户“Bill”打电话,所以当他接听电话时,电话应该重定向到 Bill 选择的另一个客户,让我们说“Joe” ”。因此,比尔点击了一个按钮,他的电话响了,他接听并开始给乔打电话。当其中一些人挂断电话时,所有通话就应该结束。有人做过吗?帮我!我很抱歉我的英语不好(哦是的,我正在使用 php)

Ale*_*ban 5

这只是让您开始的简单操作,您还可以查看连接到会议室https://www.twilio.com/docs/api/twiml/conference

您需要使用Twilio PHP Helper Library(其中的“Services”文件夹),从https://www.twilio.com/docs/libraries/php#install-via-zip-file下载

项目结构

/
/Services
/callBill.php
/callJoe.php
Run Code Online (Sandbox Code Playgroud)

呼叫帐单.php

<?php
    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>

<Response>
    <!-- // calling Bill -->
</Response>

<?php
    // Include the Twilio PHP library
    require 'Services/Twilio.php';

    // Twilio REST API version
    $version = "2010-04-01";

    // Set our Account SID and AuthToken
    $sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
    $token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

    // A phone number you have at Twilio
    $phonenumber = '5557779999';

    // The URL Twilio will request when the call is answered            
    $twilioRequestUrl = "http://somewebsite.xyz/callJoe.php";

    // Instantiate a new Twilio Rest Client
    $client = new Services_Twilio($sid, $token, $version);

    try {

        // Initiate a new outbound call
        $call = $client->account->calls->create(
            $phonenumber, // The number of the phone initiating the call
            '7779995555', // call Bill at 7779995555
            $twilioRequestUrl 
        );
        //echo 'Started call: ' . $call->sid;
    } catch (Exception $e) {
        //echo 'Error: ' . $e->getMessage();
    }

?>
Run Code Online (Sandbox Code Playgroud)

呼叫乔.php

<?php

    header("content-type: text/xml");
    echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
?>

<!-- call and connect Joe at 9995557777 with Bill's caller ID-->
<Response>
    <Pause length="2"/>
    <Say>Please wait, I'm calling Joe.</Say>
    <Dial callerId="7779995555">9995557777</Dial>
</Response>
Run Code Online (Sandbox Code Playgroud)

使用浏览器或单击按钮请求http://somewebsite.xyz/callBill.php 。