Я пытаюсь удерживать / разблокировать с помощью twilio javascript sdk и php. Способен соединить вызов, но при выполнении unhold административные вызовы разъединяются, и дочерний вызов продолжается .. не получая повторное соединение вызова.
Ниже мой полный поток кода:
1)
public function getTwilioVoiceResponse(){
$this->layout = false;
$this->autoRender = false;
$TWILIO_ACCOUNT_SID = 'ACxxxxxxxxxxxxxxxxxxxxxx';
$TWILIO_AUTH_TOKEN = 'exxxxxxxxxxxxxxxxxxxxxxx';
$TWILIO_TWIML_APP_SID = 'APXXXXXXXXXXXXXXXXXXXXXXX';
$TWILIO_CALLER_ID = '+18888888';
$response = new Twiml;
// get the phone number from the page request parameters, if given
if (isset($_REQUEST['To']) && strlen($_REQUEST['To']) > 0) {
$number = htmlspecialchars($_REQUEST['To']);
$dial = $response->dial(array('callerId' => $TWILIO_CALLER_ID , "record"=>"record-from-answer-dual" , "action"=>"https://hostname/leads/twillioHoldStatus1"));
// wrap the phone number or client name in the appropriate TwiML verb
if (preg_match("/^[\d\+\-\(\) ]+$/", $number)) {
$dial->number($number);
} else {
$dial->client($number);
}
$response->redirect("https://hostname/leads/getTwilioCallEnqueue");
}
header('Content-Type: text/xml');
echo $response;
exit;
}
2)
public function twillioHoldStatus1(){
$this->layout = false;
$this->autoRender = false;
header('Content-Type: text/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";
if ( $_REQUEST['DialCallStatus'] == 'completed' ) {
echo '<Response><Hangup/></Response>';
}else {
echo '<Response><Play>http://demo.twilio.com/docs/classic.mp3</Play><Redirect>https://hostname/leads/twillioHoldStatus1</Redirect></Response>';
}
exit;
}
3) для обновления
public function getTwilioHoldStatus( $action = "unhold" , $call_sid= NULL ){
$TWILIO_CALL_SID = $call_sid;
$client = new Client($TWILIO_ACCOUNT_SID, $TWILIO_AUTH_TOKEN);
if($action == "hold"){
$call = $client->calls->read( array("ParentCallSid" => $TWILIO_CALL_SID))[0];
$call->update( array( "url" => "https://localhost/leads/getTwilioCallEnqueue", 'Hold' => true, "method" => "POST") );
}
else{
$call = $client->calls->read( array("ParentCallSid" => $TWILIO_CALL_SID))[0];
$call->update( array("url" => "https://dev2.argusplatform.com/leads/getTwilioCallunhold", "method" => "POST" ));
}
$response["flag"] = true;
echo json_encode($response);
exit;
}
4)
public function getTwilioCallEnqueue(){
$this->layout = false;
$this->autoRender = false;
header('Content-Type: text/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo "<Response>
<Enqueue waitUrl='https://localhost/leads/getTwilioWaitMusic'>18888888</Enqueue>
</Response>";
exit;
}
5)
public function getTwilioWaitMusic(){
$this->layout = false;
$this->autoRender = false;
$response = new Twilio\TwiML\VoiceResponse();
$response->say('Call On Hold');
$response->play('https://api.twilio.com/cowbell.mp3', array("loop" => 5));
header('Content-Type: text/xml');
print $response;
exit;
}
6)
public function getTwilioCallunhold(){
$this->layout = false;
$this->autoRender = false;
$response = new Twilio\TwiML\VoiceResponse();
header('Content-Type: text/xml');
echo "<?xml version='1.0' encoding='UTF-8'?>";
echo '<Response><Dial action="https://localhost/leads/twillioHoldStatus1"><Queue>18134524218</Queue></Dial> </Response>';
exit;
}
Пожалуйста, помогите мне с приведенным выше исправлением примера. Спасибо ..