phptwilioconference

Twilio Studio Calls Drop


Using Twilio Studio if I link to my conference script the call drops as soon as the post returns 200.

Is there a way to keep the call active?

<?php
// Get the PHP helper library from https://twilio.com/docs/libraries/php

// this line loads the library 
require $_SERVER['DOCUMENT_ROOT'] . '/vendor/twilio-php-master/Twilio/autoload.php';
use Twilio\Twiml;

// Update with your own phone number in E.164 format
$MODERATOR = '0000';

$response = new Twiml;

// Start with a <Dial> verb
$dial = $response->dial();

// If the caller is our MODERATOR, then start the conference when they
// join and end the conference when they leave
if ($_REQUEST['From'] == $MODERATOR) {
  $dial->conference('My conference', array(
                'startConferenceOnEnter' => True,
                'endConferenceOnExit' => True
                ));
} else {
  // Otherwise have the caller join as a regular participant
  $dial->conference('My conference', array(
                'startConferenceOnEnter' => True
                ));
}

print $response;

?>

enter image description here


Solution

  • Twilio developer evangelist here.

    Rather than use an HTTP request here, why not use the Connect Call To widget to connect calls to a conference?

    enter image description here

    If you need to use the HTTP request, make sure your PHP sets the Content-Type header to text/xml or application/xml with header('Content-type: text/xml'); before you echo the response.