在两个未在 twilio 中注册的号码之间拨打电话 [英] Make a call between two numbers not registered in twilio

查看:26
本文介绍了在两个未在 twilio 中注册的号码之间拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

解决方案

这只是让您入门的简单方法,您还可以查看连接到会议室 https://www.twilio.com/docs/api/twiml/conference

您将需要使用从 https://www.twilio.com/docs/libraries/php#install-via-zip-file

项目结构

<预><代码>//服务/callBill.php/callJoe.php

callBill.php

<回应><!--//呼叫比尔--></响应><?php//包含 Twilio PHP 库需要服务/Twilio.php";//Twilio REST API 版本$version = "2010-04-01";//设置我们的帐户 SID 和 AuthToken$sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';$token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';//你在 Twilio 的电话号码$phonenumber = '5557779999';//接听电话时 Twilio 将请求的 URL$twilioRequestUrl = "http://somewebsite.xyz/callJoe.php";//实例化一个新的 Twilio Rest Client$client = new Services_Twilio($sid, $token, $version);尝试 {//发起一个新的外呼$call = $client->account->calls->create($phonenumber,//发起呼叫的电话号码'7779995555',//拨打比尔 7779995555$twilioRequestUrl);//echo '开始通话:' .$call->sid;} 捕获(异常 $e){//回显'错误:'.$e->getMessage();}?>

callJoe.php

<!-- 拨打 9995557777 与 Joe 联系--><回应><暂停长度="2"/><说>请稍等,我正在给乔打电话.</说><拨号>9995557777</拨号></响应>

使用浏览器或点击http://somewebsite.xyz/callBill.php一个按钮.

There's some way of make a call between two of my users? I mean... I have a twilio acount with a registered number and I have to make a call to my client "Bill" so when he answer that, the call should be redirected to another client, that Bill choosed, let's say "Joe". So, Bill click's a button and he's phone rings, he answer that and start to call Joe. When some of them hangup, the all call should be over. Have someone ever made that? Help me! And I'm sorry about my bad english (oh yeah, I'm using php for that)

解决方案

This is just something simple to get you going, you can also look at connecting to a conference room https://www.twilio.com/docs/api/twiml/conference

You will need to use the Twilio PHP Helper Library (the "Services" folder from there) download from https://www.twilio.com/docs/libraries/php#install-via-zip-file

Project structure

/
/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>

Request http://somewebsite.xyz/callBill.php with your browser or with a click on a button.

这篇关于在两个未在 twilio 中注册的号码之间拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆