- <?php
- // The URL where Chloe is running.
- define("CHLOE_ENDPOINT", "");
- // Conference identifier.
- define("CONFERENCE_ID", 9999999999);
- // Function to send data to Chloe server.
- function sendEvent($event, $id, $callerID) {
- $data = array("event" => $event, "id" => $id, "callerID" => $callerID);
- $postData = "data=" . json_encode($data);
- $ch = $ch = curl_init(CHLOE_ENDPOINT);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
- $result = curl_exec($ch);
- $error = curl_error($ch);
- $curl_http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if($result === false) {
- _log("An error occurred: ".$error);
- return false;
- }
- else {
- if ($curl_http_code != '200') {
- _log("*** An error occurred: Invalid HTTP response returned: " . $curl_http_code);
- return false;
- }
- return true;
- }
- }
- // Call properties.
- $callerID = $currentCall->callerID;
- $id = $currentCall->id;
- // Send a join event to Chloe.
- if(sendEvent("join", $id, $callerID)) {
- say("Welcome to the conference. Press the pound key to exit.");
- }
- else {
- say("Sorry, there was a problem joining you to the conference.");
- hangup();
- }
- // Place caller in conference.
- conference(CONFERENCE_ID, array("terminator" => "#"));
- // Send exit event to Chloe.
- sendEvent("exit", $id, $callerID);
- // Exit prompt for caller.
- say("Thank you for joining the conference, goodbye.");
- ?>