Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/265.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Twilio-将两个呼叫者放在同一个动态生成的会议室中创建无限循环_Php_Twilio - Fatal编程技术网

Php Twilio-将两个呼叫者放在同一个动态生成的会议室中创建无限循环

Php Twilio-将两个呼叫者放在同一个动态生成的会议室中创建无限循环,php,twilio,Php,Twilio,我以前见过一些Twilio专家在这里回答关于使用Twilio服务的其他问题,所以我希望这能引起其中一位专家的注意。:) 本质上,我需要创建一个系统,让两个呼叫者(一个销售代理和一个客户)能够连接,让经理能够监听现场通话。根据我对Twilio API的研究,我认为实现这一点的唯一方法是让每次通话都成为会议通话,并允许经理以“静音”模式加入该通话,从而只允许他们监听代理和客户之间的通话 我正在用PHP开发,我相信我已经解决了90%的难题,但是我在一个小细节上遇到了麻烦 我将在下面列出逻辑流程,以便您

我以前见过一些Twilio专家在这里回答关于使用Twilio服务的其他问题,所以我希望这能引起其中一位专家的注意。:)

本质上,我需要创建一个系统,让两个呼叫者(一个销售代理和一个客户)能够连接,让经理能够监听现场通话。根据我对Twilio API的研究,我认为实现这一点的唯一方法是让每次通话都成为会议通话,并允许经理以“静音”模式加入该通话,从而只允许他们监听代理和客户之间的通话

我正在用PHP开发,我相信我已经解决了90%的难题,但是我在一个小细节上遇到了麻烦

我将在下面列出逻辑流程,以便您可以看到我正在尝试做什么:

1) 客户或销售代理拨打一个号码

2) 动态生成会议室,并将拨出的人放入该会议室

3) 我使用RESTAPI向另一个电话号码发出呼叫请求,然后将他们引导到第一个人等待时已经生成的会议室

我已经完成了第1步和第2步,工作正常,第3步就是问题发生的地方。当我使用API生成第二个调用以将另一个人带入会议室时,请求将通过与生成第一个调用相同的应用程序,从而创建一个无限循环,生成新调用和新会议室。我在下面附上了我的代码来帮助解释这个问题

public function index()
{
   if (isset($_REQUEST['PhoneNumber'])) {
        // The agent is making a call (outgoing)
        $data['callerId']  = $this->users->getPhoneNumber($_REQUEST['Caller']);
        $userIdExplode = explode(':', $_REQUEST['Caller']);
        $data['userId'] = $userIdExplode[1];
        $callTarget = $this->security->xss_clean($_REQUEST['PhoneNumber']);
        $data['numberOrClient'] = "<Number>" . $callTarget . "</Number>";
        $data['phoneIsOnline']  = $this->users->isPhoneOnline($data['userId']);

        // Call log information
        $data['ani']  = $data['callerId'];
        $data['dnis'] = $callTarget;

    } elseif (isset($_REQUEST['To'])) { 

        // The agent is receiving a call (incoming)
        $callTarget = $this->security->xss_clean($_REQUEST['To']);
        $data['userId'] = $this->users->getIdByPhoneNumber($callTarget);
        $data['numberOrClient'] = "<Client>" . $data['userId'] . "</Client>";
        $data['phoneIsOnline']  = $this->users->isPhoneOnline($data['userId']);

        // Call log information
        $data['ani']  = $_REQUEST['From'];
        $data['dnis'] = $_REQUEST['To'];
    }

    // Log the new call and receive it's log ID
    $data['callLogId'] = $this->call->logNewCall($data['ani'], $data['dnis'], $data['userId']);

    // Load the TWIML (Twilio XML) to bring the caller into a conference room
    $this->load->view('twilio/connections_twiml', $data);

    // Bring the destination number into the same conference room as the origin number 
    $this->dialToConference($data['ani'], $data['dnis'], $data['callLogId']);
}

public function dialToConference($caller, $callee, $confNum) 
{
    // Twilio capability library (capable of incoming and outgoing calls)
    include APPPATH . 'libraries/twilio/Services/Twilio.php';

    // Twilio account codes required for the client
    $accountSid = $this->config->item('twilio_accountSid');
    $authToken  = $this->config->item('twilio_authToken');

    $client = new Services_Twilio($accountSid, $authToken);
    $call = $client->account->calls->create(
        $caller,
        $callee,
        BASE_URL . 'twilio/twilio_connections/loadConferenceTwiml?conferenceId=' . $confNum
    );
}
公共功能索引()
{
如果(isset($_请求['PhoneNumber'])){
//代理正在打电话(传出)
$data['callerId']=$this->users->getPhoneNumber($_请求['Caller']);
$userIdExplode=explode(“:”,$\u请求['Caller']);
$data['userId']=$userIdExplode[1];
$callTarget=$this->security->xss_clean($_请求['PhoneNumber']);
$data['numberrorclient']=“.$callTarget.”;
$data['phoneIsOnline']=$this->users->isPhoneOnline($data['userId']);
//通话记录信息
$data['ani']=$data['callerId'];
$data['dnis']=$callTarget;
}elseif(isset($_请求['To']){
//代理正在接收呼叫(传入)
$callTarget=$this->security->xss_clean($_REQUEST['To']);
$data['userId']=$this->users->getIdByPhoneNumber($callTarget);
$data['numberrorclient']=”.$data['userId']。”;
$data['phoneIsOnline']=$this->users->isPhoneOnline($data['userId']);
//通话记录信息
$data['ani']=$_请求['From'];
$data['dnis']=$\请求['To'];
}
//记录新呼叫并接收其日志ID
$data['callLogId']=$this->call->logNewCall($data['ani'],$data['dnis'],$data['userId']);
//加载TWIML(twilioxml)以将呼叫者带入会议室
$this->load->view('twilio/connections\u twiml',$data);
//将目的地号码与出发地号码放入同一会议室
$this->dialToConference($data['ani'],$data['dnis'],$data['callLogId']);
}
公用函数拨号会议($caller,$callee,$confNum)
{
//Twilio功能库(支持传入和传出呼叫)
包括APPPATH.“libraries/twilio/Services/twilio.php”;
//客户所需的Twilio帐户代码
$accountSid=$this->config->item('twilio_accountSid');
$authToken=$this->config->item('twilio_authToken');
$client=newservices\u twillio($accountSid,$authToken);
$call=$client->account->calls->create(
$caller,
$callee,
基本URL。“twilio/twilio\u连接/loadConferenceTwiml?conferenceId=”。$confNum
);
}

Twilio福音传道者在这里。看起来您正在将生成的会议ID作为语音URL的查询字符串参数传递回Twilio,这是一种很好的方法。但是我没有看到在索引函数中,您希望查看是否设置了请求参数,以及是否跳过对dialToConference函数的调用。那有帮助吗?嘿,德文,你帮了不少忙。我不知道为什么我没有考虑检查变量是否设置好了…盯着代码看了太久:)@Kody458问题解决了吗?