[gestion_api]
exten=>_x.,1,Agi(/var/www/html/gestion/info.php,${CALLERID(num)},${EXTEN})
same=>n,Noop( time out value ${timeout})
same=>n,Set(TIMEOUT(absolute)=${timeout})
same=>n,goto(from-trunk,${EXTEN},1)
example reponse
{"blocked":0,"timer":0}
#!/usr/bin/php -q
<?php
error_reporting(E_ALL);
set_time_limit(30);
//require_once('/root/phpagi-svn/phpagi.php');
require_once('/var/lib/asterisk/agi-bin/phpagi-2.20/phpagi.php');
$agi = new AGI();
$agi->answer();
$agi->stream_file("silence/1");
$url=file_get_contents("http://181.31.221.173/match_info.php?cid=$argv[1]&did=$argv[2]");
$url=json_decode($url, true);
$agi->verbose("$url[blocked] $argv[1] $argv[2] ***");
$agi->verbose("$url[timer] ***");
$agi->verbose("continue with the script execution ***");
if ($url[blocked]>0){
echo " calls blocked";
$agi->verbose("calls blocked");
$agi->stream_file("im-sorry");
$agi->hangup();
exit();
}
else {
//$agi->stream_file("auth-thankyou");
$agi->set_autohangup($url[blocked]);
$agi->verbose("calls allowed");
$agi->set_variable("timeout",$url[timer]);
}
exit();
?>
No hay comentarios:
Publicar un comentario