URL to post data: http://api.humbuglabs.org/receiver.php
Parameter
gateway
encoded
Event
Source
Destination
DestinationContext
CallerID
Channel
DestinationChannel
StartTime
AnswerTime
EndTime
Duration
BillableSeconds
Disposition
UniqueID
UserField
event_time
Description
(string, required) – Your API KEY
(int, required) – set to 1 if sending encoding data, 0 otherwise
(string, required) – type of event. For sending CDR data, set this to: Cdr
(string, required) – call originator in standard e.164 format. For example, a number in the UK would look like: 44207xxxxxxx
(string, required) – call termination in standard e.164 format. For example, a number in the UK would look like: 44207xxxxxxx
(string, required) – Context of the call. You can set this to "inbound" or "outbound" to determine the behaviour of the call
(string, required) – caller ID
(string, required) – originating channel, in the format of: Protocol/Trunk. For example, this might look like: SIP/att_inbound
(string) – terminating channel in the format of: Protocol/Trunk. For example, this might look like: SIP/att_outbound
(DateTime, required) – start of the call; i.e. 2011-12-01 23:59:59
(DateTime, required) – time call was answered; i.e. 2011-12-01 23:59:59
(DateTime, required) - end of the call; i.e. 2011-12-01 23:59:59
(int, required) – duration of the call in seconds
(int, required) – billable seconds
(string, required) – disposition of the call. Some dispositions might be: ANSWERED, NO ANSWER, BUSY, FAILED, CANCEL, ERROR, CONGENSTION
(string, required) – custom unique ID of the call. This can be helpful for tracking data between your system and Humbug's records.
(string, optional) – Set this to "inbound" or "outbound" to set behavior of the call
(DateTime, optional) – Local time of your application/PBX
Sample CDR POST Request:
gateway=YOUR_APIKEY&encoded=0&Event=Cdr&Source=15558624&Destination=155511044&DestinationContext=outbound&CallerID=15558624&Channel=SIP/trunk_name-000&DestinationChannel=SIP/trunk_name-0000&StartTime=2011-01-25 13:41:39&AnswerTime=2011-01-25 13:41:48&EndTime=2011-01-25 13:41:48&Duration=42&BillableSeconds=39&Disposition=ANSWERED&UniqueID=123456789.001&UserField=outbound&event_time=2011-01-25 13:41:48
PHP, unencoded data example
									function send_humbug_data() {
									      //the url we are sending data to
										  $url              = 'http://api.humbuglabs.org/receiver.php';
						
										  //in our example we're building an array of the values we need to send
									      $array = array (
									            'gateway'            => 'your-api-key',
									            'encoded'            => '0',
												'Event'              => 'Cdr',
									            'Source'             => '15551234567',
									            'Destination'        => '401',
									            'DestinationContext' => 'from-internal',
									            'CallerID'           => '15551234567',
									            'Channel'            => 'SIP/401@from-queue-aeff',
									            'DestinationChannel' => 'SIP/Trunk_out_01-0000000e',
									            'LastApplication'    => 'Dial',
									            'LastData'           => 'SIP/Trunk_out/15551234567,,trM(blkvm)',
									            'StartTime'          => '2011-01-11 12:15:08',
									            'AnswerTime'         => '2011-01-11 12:15:13',
									            'EndTime'            => '2011-01-11 12:55:45',
									            'Duration'           => '2437',
									            'BillableSeconds'    => '2432',
									            'Disposition'        => 'ANSWER',
									            'UniqueID'           => '123456.123',
									            'UserField'        	 => 'inbound',
									            'event_time'         => date('Y-m-d h:i:s',time())
									            );
										
										  //turn the array into a key=value string for usage with cURL
										  $params    = "";
									      foreach($array as $key => $value) {
									            $params .= $key.'='.$value.'&';
									      }
									      rtrim($params,'&');
										  
										  //send the data
									      $ch = curl_init();
									      curl_setopt($ch,CURLOPT_URL,$url);
									      curl_setopt($ch,CURLOPT_POST,count($array));
									      curl_setopt($ch,CURLOPT_POSTFIELDS,$params);
									      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
									      $result = curl_exec($ch);
									      curl_close($ch);
									}
						
								
PHP, encoded data example
									function send_encoded_humbug_data() {
						
										  //prepare the variables
										  $apikey     = "your-api-key";
										  $key        = "your-humbug-encryption-key";
										  
										  $key_chars  = str_split($key, 1);
										  $key_length = strlen ( $key );
						
									      //the url we are sending data to
										  $url        = 'http://api.humbuglabs.org/receiver.php';
						
										  //in our example we're building an array of the values we need to send
									      $array = array (
									            'gateway'            => $apikey,
									            'encoded'            => '1',
												'Event'              => 'Cdr',
									            'Source'             => '15551234567',
									            'Destination'        => '401',
									            'DestinationContext' => 'from-internal',
									            'CallerID'           => '15551234567',
									            'Channel'            => 'SIP/401@from-queue-aeff',
									            'DestinationChannel' => 'SIP/Trunk_out_01-0000000e',
									            'LastApplication'    => 'Dial',
									            'LastData'           => 'SIP/Trunk_out/15551234567,,trM(blkvm)',
									            'StartTime'          => '2011-01-11 12:15:08',
									            'AnswerTime'         => '2011-01-11 12:15:13',
									            'EndTime'            => '2011-01-11 12:55:45',
									            'Duration'           => '2437',
									            'BillableSeconds'    => '2432',
									            'Disposition'        => 'ANSWER',
									            'UniqueID'           => '123456.123',
									            'UserField'        	 => 'inbound'
									            );
										
										  //turn the array into a key=value string for usage with cURL
										  $params    = "";
									      foreach($array as $key => $value) {
									            $params .= $key.'='.$value.'&';
									      }
									      rtrim($params,'&');
										
						
										  //encode the data
										  $params_char = str_split($params, 1);
										  $str = "";
										  $i = 0;
										  foreach ( $params_char as $sym ) {
										      if ( $i == $key_length ) { $i = 0; }
									   	      $str .= sprintf ( '%02x', ord($sym ^ $key_chars[$i]));
										      $i++;
										  }
										  
										  //build a new encoded request
										  $request = "gateway=".$apikey."&encoded=1&data=".$str; 
										  
										  //add an event_time
										  $request .="&event_time=".date('Y-m-d h:i:s',time());
										  
										  //send the data
									      $ch = curl_init();
									      curl_setopt($ch,CURLOPT_URL,$url);
									      curl_setopt($ch,CURLOPT_POST,3);
									      curl_setopt($ch,CURLOPT_POSTFIELDS,$request);
									      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
									      $result = curl_exec($ch);
									      curl_close($ch);
									}
						
								
  • When in doubt, leave required fields with "0" or blank, or contact us for help