|
<?php
/* http://45.32.165.238/ami/webcall.php?src=101&dst=8095445555&trunk=400&cid=18007142323 */
$timeout=100;
$host="127.0.0.1";
$port=5038;
$src = preg_replace('/\s+/', '', $_GET[src]);
$dst = preg_replace('/\s+/', '', $_GET[dst]);
$trunk = preg_replace('/\s+/', '', $_GET[trunk]);
$cid = preg_replace('/\s+/', '', $_GET[cid]);
$id = preg_replace('/\s+/', '', $_GET[id]);
$pitch = preg_replace('/\s+/', '', $_GET[pitch]);
$num=$dst;
$ext=$src ;
$context="outbound-click-to-call";
$socket = fsockopen("$host",$port,$errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: admin\r\n"); //
fputs($socket, "Secret: Krtzv\r\n\r\n"); // //
$wrets=fgets($socket,128);
fputs($socket, "Action: Originate\r\n" );
fputs($socket, "Channel: Local/$src@from-internal/n\r\n" );
fputs($socket, "Exten: $dst\r\n" );
fputs($socket, "Context: $context\r\n" );
fputs($socket, "Priority: 1\r\n" );
fputs($socket, "CallerID: $cid\r\n" );
fputs($socket, "Variable: __trunk=$trunk\r\n" );
fputs($socket, "Variable: __dst=$dst\r\n" );
fputs($socket, "Variable: __src=$src\r\n" );
fputs($socket, "Variable: __cid=$cid\r\n" );
fputs($socket, "Variable: __id=$id\r\n" );
fputs($socket, "Variable: __pitch=$pitch\r\n" );
fputs($socket, "Async: yes\r\n\r\n" );
fputs($socket, "Action: Logoff\r\n\r\n");
sleep (1);
$wrets=fgets($socket,128);
echo $wrets;
?>
<?php |
| // Define the API endpoint |
| $url = 'https://asterisk-voip.com'; |
|
|
| // Initialize a cURL session |
| $ch = curl_init($url); |
|
|
| // Define the headers |
| $headers = [ |
| 'Accept: application/json', |
| 'Authorization: Basic 12345password', |
| 'Content-Type: multipart/form-data', |
| 'X-CSRF-TOKEN: ' |
| ]; |
|
|
| // Define the form data |
| $postFields = [ |
| 'to' => "$argv[1]", |
| 'from' => "$argv[2]", |
| 'recording_file' => new CURLFile("$argv[3]"), // Replace with the actual file path |
| 'start_time' => "$argv[5]", |
| 'end_time' => "$argv[6]", |
| 'call_length' => "$argv[4] Seconds" |
| ]; |
|
|
| // Set the cURL options |
| curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| curl_setopt($ch, CURLOPT_POST, true); |
| curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
| curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields); |
|
|
|
|
| // Execute the request |
| $response = curl_exec($ch); |
|
|
| // Check for errors |
| if (curl_errno($ch)) { |
| echo 'Error:' . curl_error($ch); |
| } else { |
| // Print the response |
| echo $response; |
| } |
|
|
| // Close the cURL session |
| curl_close($ch); |
| ?> |
|
|
| |
| --------- |
| [outbound-click-to-call] |
|
|
| exten => _X.,1,Set(calltime=${STRFTIME(${EPOCH},,%Y%m%d%H%M%S)}) |
|
|
| same => n,Set(path=/var/www/html/click_2_call/monitor) |
|
|
| same => n,MixMonitor(${path}/${calltime}-${CALLERID(num)}-${EXTEN:3}.wav) |
|
|
| same=>n,Set(CALLERID(num)=9496504600) |
|
|
| same => n,Dial(PJSIP/${EXTEN}@Synapseglobal,120) |
|
|
|
|
|
|
| exten => h,1,Set(start_time=${CUT(CDR(start), ,2)}) ; Extract the time portion |
|
|
| same => n,Set(end_time=${CUT(CDR(end), ,2)}) |
|
|
| same => n,NoOp(Start Time Portion: ${start_time}) |
|
|
| same => n,NoOp(End Time Portion: ${end_time}) |
|
|
| same => n,Set(result=${SHELL(php /var/www/html/click_2_call/post_cdr.php "${CDR(dst)}" "${CDR(src)}" "${MIXMONITOR_FILENAME}" "${CDR(billsec)}" "${start_time}" "${end_time}")}) |
|
|
| same=>n,hangup() |
|
|
|
|
|
No hay comentarios:
Publicar un comentario