2

2 人のユーザー間で電話をかける方法はありますか? つまり... 私は登録済みの電話番号を持つ twilio アカウントを持っており、クライアントの "Bill" に電話をかけなければならないので、彼が応答すると、その電話は Bill が選択した別のクライアントにリダイレクトされるはずです。たとえば、"Joe "。ビルがボタンをクリックすると電話が鳴り、それに応答してジョーに電話をかけ始めます。それらのいくつかがハングアップすると、すべての通話が終了するはずです。誰かがそれを作ったことがありますか?助けて!そして、私の悪い英語について申し訳ありません(ああ、そうです、私はそのためにphpを使用しています)

4

1 に答える 1

4

これは簡単なことです。会議室への接続も確認できますhttps://www.twilio.com/docs/api/twiml/conference

https://www.twilio.com/docs/libraries/php#install-via-zip-fileからダウンロードしたTwilio PHP Helper Library (そこにある「Services」フォルダー)を使用する必要があります。

プロジェクトの構造

/
/Services
/callBill.php
/callJoe.php

callBill.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();
    }

?>

callJoe.php

<?php

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

<!-- call and connect Joe at 9995557777 -->
<Response>
    <Pause length="2"/>
    <Say>Please wait, I'm calling Joe.</Say>
    <Dial>9995557777</Dial>
</Response>

ブラウザまたはボタンをクリックしてhttp://somewebsite.xyz/callBill.phpをリクエストします。

于 2016-06-23T01:16:47.623 に答える