, Asterisk REST Interface. API Asterisk. , SIP ARI Telegram.
ARI
FreePBX Settings → → Advanced Settings Asterisk REST Interface:

:
- Enable the Asterisk REST Interface - Yes;
- ARI Username - ;
- Allowed Origins - *;
- ARI Password - ;
- Pretty Print JSON Responses - Yes;
- Web Socket Write Timeout - 100;
.
Telegram
, Telegram . , . :)
PHP -
, . :
<?php # Telegram $token = ""; $chat_id = "id_"; # REST API Asterisk $json_url = 'http://localhost:8088/ari/endpoints/SIP'; $username = 'ARI_Username'; // $password = 'ARI_Password'; // # REST $ch = curl_init($json_url); $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_USERPWD => $username . ":" . $password, CURLOPT_HTTPHEADER => array('Content-type: application/json') , ); curl_setopt_array( $ch, $options ); $result = curl_exec($ch); // JSON $result = json_decode($result, true); # , Telegram $telegram = array( 0 => array ( ' SIP .' => ':', )); $num = 1; //print_r($result); foreach($result as $number => $massiv) { foreach($massiv as $key => $value) { # , online if (($key == 'state') && ($value != 'online')) { $telegram[$num] = array( ' '.$massiv['resource'].'' => ' '.$massiv['state'].'', ); $num = $num + 1; } else { }}}; # Telegram , , online if ($num > 1) { foreach($telegram as $key => $value) { foreach($value as $dev => $status) { $txt .= "<b>".$dev."</b> ".$status."%0A"; }}; fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");}; ?>
, .txt .php
( ari_monitoring.php), /home/scripts
cron:
crontab e
2 :
*/2 * * * * /usr/bin/php /home/scripts/ari_monitoring.php
, , :
