Asterisk Telegram -

FreePBX Asterisk

Asterisk

numverify

, , ? (, 1 , 2 , 3 , 4 ), , , , : ! COMPANY_NAME. +2, . , ?

, . Asterisk :)

. ? API. , . , :)



numverify.com

numverify. API, , 250 API (12 13 ). :

   numverify

Sign Up , ( ) API :

 API

API Asterisk.


Telegram -

, Telegram . , ( API ID - ):


AGI

API Telegram ID . AGI Telegram :) :

#!/usr/bin/php -q
<?php
# callerid
require('phpagi.php'); 
$agi = new AGI(); 
$cid = $agi->request['agi_callerid'];
#    Telegram
$token = "_api__Telegram";
$chat_id = "ID_";
#  api -   numverify
$apikey = "api___numverify";
# 10       7  (    )
$phone_loc = substr($cid, -10);
$phone_loc = "7$phone_loc";
#  API   
$numverify_url = "http://apilayer.net/api/validate?access_key=$apikey&number=$phone_loc";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$numverify_url);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$numverify = curl_exec ($ch);
curl_close($ch);
# JSON
$numverify_o = json_decode($numverify, true);
print_r ($numverify_o);
#      Telegram
$arr = array(
',  :' => $cid,
' :' => $numverify_o['country_code'],
' :' => $numverify_o['country_name'],
':' => $numverify_o['location'],
'  (/):' => $numverify_o['line_type'],
);
foreach($arr as $key => $value) {
$txt .= "".$key." ".$value."%0A";
};
#    API Telegram
fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
?>

, .txt .php

! numverify.php /var/lib/asterisk/agi-bin. WinSCP, . , SSH Asterisk :

dos2unix /var/lib/asterisk/agi-bin/numverify.php
chown asterisk:asterisk /var/lib/asterisk/agi-bin/numverify.php
chmod 775 /var/lib/asterisk/agi-bin/numverify.php

. , :

exten => _.,n,AGI(numverify.php)

:

dialplan reload

, , . 4996491913:

landline - , mobile - . numverify

! ? :)

      Asterisk

. , . , 1, 2, 3 . . :


?