0

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

Jason
  • 57
  • 6

1 Answers1

1

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.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thanks for the heads up. I'm using that method so that I can log the call via PHP as I can't seem to get the HTTP Post widget to send the $_POST["From"] – Jason May 01 '18 at 10:30
  • How are you trying to send the `From` in the Post widget? – philnash May 01 '18 at 10:34
  • same as in my screenshot on the first post.. URL > POST but I can't seem to hook onto $_POST["From"] in my php script. – Jason May 01 '18 at 11:30
  • 1
    Oh, you'll need to add the parameters to the POST request body in the widget. Try something like `From={{ flow.trigger.call.From }}`. – philnash May 01 '18 at 23:05