Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 1.51 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. // The URL where Chloe is running.
  4. define("CHLOE_ENDPOINT", "");
  5.  
  6. // Conference identifier.
  7. define("CONFERENCE_ID", 9999999999);
  8.  
  9. // Function to send data to Chloe server.
  10. function sendEvent($event, $id, $callerID) {
  11.        
  12.         $data = array("event" => $event, "id" => $id, "callerID" => $callerID);
  13.         $postData = "data=" . json_encode($data);
  14.        
  15.         $ch = $ch = curl_init(CHLOE_ENDPOINT);
  16.         curl_setopt($ch, CURLOPT_POST, true);
  17.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  18.         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
  19.         curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
  20.        
  21.         $result = curl_exec($ch);
  22.         $error = curl_error($ch);
  23.         $curl_http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  24.                
  25.         if($result === false) {
  26.                 _log("An error occurred: ".$error);
  27.                 return false;
  28.         }
  29.         else {
  30.            if ($curl_http_code != '200') {
  31.                 _log("*** An error occurred: Invalid HTTP response returned: " . $curl_http_code);
  32.                 return false;
  33.            }
  34.           return true;
  35.         }      
  36.        
  37. }
  38.  
  39. // Call properties.
  40. $callerID = $currentCall->callerID;
  41. $id = $currentCall->id;
  42.  
  43. // Send a join event to Chloe.
  44. if(sendEvent("join", $id, $callerID)) {
  45.         say("Welcome to the conference. Press the pound key to exit.");
  46. }
  47. else {
  48.         say("Sorry, there was a problem joining you to the conference.");
  49.         hangup();
  50. }
  51.  
  52. // Place caller in conference.
  53. conference(CONFERENCE_ID, array("terminator" => "#"));
  54.  
  55. // Send exit event to Chloe.
  56. sendEvent("exit", $id, $callerID);
  57.  
  58. // Exit prompt for caller.
  59. say("Thank you for joining the conference, goodbye.");
  60.  
  61.  
  62. ?>