<?php

// Include the PHP Plivo Rest library
require "./plivohelper.php";
$base_http = "http://" . dirname($_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"]);
/* Render RESTXML */
$r = new Response();
$r->addConference("plivo", array('muted' => 'false', 'enterSound' => "beep:2", 'exitSound' => "beep:1", 'startConferenceOnEnter' => "true", 'endConferenceOnExit' => "true", 'waitSound' => $base_http . "/duck.mp3", 'timeLimit' => 60, 'hangupOnStar' => 'true'));
$r->Respond();
<?php

require_once "./plivo.php";
# Generates a Conference XML
$r = new Response();
$params = array('enterSound' => "beep:1", 'callbackUrl' => "https://example.com/conf_callback.php", 'callbackMethod' => "GET");
$name = "demo";
$r->addSpeak("You will now be placed into a demo conference. This is brought to you by Plivo. To know more visit us at plivo.com");
$r->addConference($name, $params);
Header('Content-type: text/xml');
echo $r->toXML();
?>

<!--conf_callback.php-->

<?php 
require_once "./plivo.php";
# Record API is called in the callback URL to record the conference
$conf_name = $_REQUEST['ConferenceName'];
$event = $_REQUEST['Event'];
print "Conference Name : {$conf_name}";
print "Event : {$event}";
# The recording starts when the user enters the conference room
if ($event == "ConferenceEnter") {
    $auth_id = "Your AUTH_ID";
    $auth_token = "Your AUTH_TOKEN";
    $p = new RestAPI($auth_id, $auth_token);
    $params = array('conference_name' => $conf_name);
    $resp = $p->record_conference($params);
    print "URL : {$resp['response']['url']}";
    print "Recording ID : {$resp['response']['recording_id']}";
         //no input handled
         $r->addPlayText('you have not entered any input');
         $_SESSION['next_goto'] = 'Menu1';
     } else {
         if ($_REQUEST['data'] == '1') {
             $_SESSION['next_goto'] = 'Record_Status';
             $r->addPlayText('Please record your message after beep ');
             //give unique file name for each recording
             $r->addRecord('filename2', 'wav', '120');
         } else {
             if ($_REQUEST['data'] == '2') {
                 $_SESSION['next_goto'] = 'DialMenu';
             } else {
                 if ($_REQUEST['data'] == '3') {
                     $r->addPlayText('your conference number is 1 2 3 4 ');
                     $r->addConference(1234);
                     $_SESSION['next_goto'] = 'Dial1_Status';
                 } else {
                     if ($_REQUEST['data'] == '4') {
                         $r->addGoto('http://127.0.0.1/kookoophp/demo_gotopage.php');
                         //update the url to redirect from demo.php to demo_gotopage.php
                         //url should be full url : 'http://host../nextapp.app' it will jump to next url
                         $_SESSION['next_goto'] = 'Menu1';
                     } else {
                         $r->addPlayText('Thats an invalid input');
                     }
                 }
             }
         }
     }
 } else {
    $collectInput->setTimeOut('4000');
    //maxtimeout if caller not give any inputs
    $collectInput->setTermChar('#');
    $r->addCollectDtmf($collectInput);
    $_SESSION['next_goto'] = 'conference';
} else {
    if ($_REQUEST['event'] == "GotDTMF" && $_SESSION['next_goto'] == 'conference') {
        if ($_REQUEST['data'] == "") {
            $collectInput = new CollectDtmf();
            $collectInput->addPlayText("You have not given any input");
            $collectInput->addPlayText('please enter the conference number again followed by hash', 3);
            $collectInput->setMaxDigits('4');
            //max inputs to be allowed
            $collectInput->setTimeOut('4000');
            //maxtimeout if caller not give any inputs
            $collectInput->setTermChar('#');
            $r->addCollectDtmf($collectInput);
            $_SESSION['next_goto'] = 'conference';
        } else {
            if ($_REQUEST['data'] == $confno[0]) {
                $r->addPlayText("Please be online while we connect you. Thank you");
                $r->addConference($confno[0]);
            } else {
                $r->addPlayText("Your input has been not matched with any our conference numbers");
            }
        }
    }
}
$r->send();
?>
 
 public function testDialAddConferenceConvience()
 {
     $r = new Response();
     $r->addConference("MyRoom", array("startConferenceOnEnter" => "false"));
     $expected = '<Response><Conference startConferenceOnEnter="false">MyRoom</Conference></Response>';
     $this->assertXmlStringEqualsXmlString($expected, $r->asUrl(False));
 }