Telegram - . ? :)

, , ( )? , , :) , , , , .

, API Asterisk AGI. , .

. API 500 , . , . .

(token)

https://developer.tech.yandex.ru :

  API
  • - . , Asterisk;
  • - API ;

, . :

API

, . AGI .


AGI - PHP

: AGI CallerID , CURL API . JSON, , . ( //):

#!/usr/bin/php -q
<?php
require('phpagi.php'); 
$agi = new AGI(); 
$cid = $agi->request['agi_callerid']; //  CallerID;
$key = 'd415b201-3d9b-45a7-95b9-000000000000'; //      API  ;
$yandex_url = "https://search-maps.yandex.ru/v1/?text=$cid&results=1&type=biz&lang=ru_RU&apikey=$key"; // URL,         ;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,$yandex_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);
$yandex = curl_exec ($ch); //       ;
curl_close($ch);
$yandex_o = json_decode($yandex, true); //  JSON  ;
$views = $yandex_o['features'][0]['properties']['CompanyMetaData']['name']; //    ,     ;
if (empty($views)) {$agi->set_variable("lookupcid", "$cid");}  else {
$agi->set_variable("lookupcid", "$views");
} //      ,        lookupcid   ,      ,      ;
?>
AGI

company_name.php /var/lib/asterisk/agi-bin :

dos2unix /var/lib/asterisk/agi-bin/company_name.php
chown asterisk:asterisk /var/lib/asterisk/agi-bin/company_name.php
chmod 775 /var/lib/asterisk/agi-bin/company_name.php
, , , , . ['features'][0]['properties']['CompanyMetaData']['Categories'][0-2]['name'];. ( 0 - 2), 1 .

. 8899:

exten => 8899,n,AGI(company_name.php)
exten => 8899,n,Set(CALLERID(name)=${lookupcid})

dialplan reload. +74996491913 :

    Asterisk      Asterisk

?

 .

P.S. , :)

"",