//print parameter data and status params value
                        $_SESSION['dial_record_url'] = $_REQUEST['data'];
                        $_SESSION['dial_status'] = $_REQUEST['status'];
                        $_SESSION['dial_callduration'] = $_REQUEST['callduration'];
                        if ($_REQUEST['status'] == 'not_answered') {
                            //if you would like dial another number, if first call not answered,
                            //
                            $r->addDial("99999999", 'true', 1000, 30, 'default');
                        } else {
                            $r->addPlayText('Thank you for calling, ');
                            $r->addHangup();
                            // do something more or send hang up to kookoo
                            // call is answered
                        }
                    } else {
                        //print you session param 'next_goto' and other details
                        $r->addPlayText('Sorry, session and events not maintained properly, Thank you for calling, have nice day');
                        $r->addHangup();
                        // do something more or to send hang up to kookoo
                    }
                }
            }
        }
    }
}
//print final response xml send to kookoo, It would help you to understand request response between kookoo and your application
//  	 	$r->getXML();
//
//$logs->writelog("final response xml addedd  ".$r->getXML().PHP_EOL." ::::\t\t\t");
fwrite($fp, "----------- final xml send to kookoo  -------------  " . $r->getXML() . "\n");
$r->send();