Twilio,In Incoming calls当我排队呼叫时第二次呼叫状态完成。但保持音乐仍在呼叫的两侧播放。这是我的代码更新呼叫。(第一次保持unhold工作正常但是当第二次尝试保持时,保持但是当我通过callsid获取呼叫信息时,callstatus就会完成。)
function hold_call($parentCallSid,$action='hold'){
echo $parentCallSid;
$admin_id = get_current_user_id();
$childCalls = $this->client->calls->read(array("ParentCallSid" => $parentCallSid));
$childCallSid = $childCalls[0]->sid;
$rr = array(
"url" => "url/TwiML/hold_unhold.php?action=$action&admin_id=".$admin_id,
"method" => "POST"
);
// echo 'CallSid-> '.$childCallSid;
$call = $this->client->calls($childCallSid)->update($rr);
$call1 = $this->client->calls($parentCallSid)->fetch();
print_r($call);
print_r($call1);
//return $call->to;
}
function unhold_call($parentCallSid,$action='unhold'){
//echo $parentCallSid;
$admin_id = get_current_user_id();
$rr = array(
"url" => "url/hold_unhold.php?action=$action&admin_id=".$admin_id,
"method" => "POST"
);
//$call = $this->client->calls->read(array("ParentCallSid" => 'CA9631b87ec900aaa309f1847872cf0da3'));
$call1 = $this->client->calls($parentCallSid)->update($rr);
print_r($call1);
//return $call->to;
}
on hol_unhold.php
if($_REQUEST['action']=='hold'){
?>
<Response>
<Enqueue waitUrl="adHoldmusic.xml"><?php echo $_REQUEST['admin_id'] ?></Enqueue>
</Response>
<?php }else{
?>
<Response>
<Dial>
<Queue><?php echo $_REQUEST['admin_id'] ?></Queue>
</Dial>
<Play loop="0"><?php echo $hold_music;?></Play>
</Response>
<?php }
并使用此twiml接收电话 -
<Response>
<Dial>
<Client statusCallbackEvent="initiated ringing answered completed" statusCallback="twilio_call_notification_handler.php" statusCallbackMethod="POST"><?php echo isset($numbers[$_REQUEST['Called']]) ? $numbers[$_REQUEST['Called']] : 'new'; ?></Client>
</Dial>
<Play loop="0"><?php echo $hold_music;?></Play>
</Response>