我是freepbx和asterisk的新手
我需要知道如何编写一个检查每个出站呼叫的应用程序,以查看该扩展是否有权限。
例如,我有2个扩展名100,200,每次扩展尝试进行出站呼叫时,我需要检查我的数据库,看看他是否拥有该权限,如果没有阻止该呼叫 抱歉,我的英语不太好答案 0 :(得分:2)
我假设您安装了Asterisk,并且已配置SIP软电话进行基本设置。
您可能需要在/etc/asterisk/extensions.conf
[internal]
exten => _XXXXXXXXXX,1,Answer()
same => n,Set(callerid=${CALLERID(num)})
same => n,Verbose(Your Callerid is ${callerid})
same => n,Saydigits(${callerid})
same => n,AGI(check_callerid.php,${callerid})
;same => n,Hangup()
[welcome]
exten => s,1,Playback(welcome)
same => n,Verbose(Allowed to call)
;same => n,Dial(SIP/trunkname/${EXTEN})
[good_bye]
exten => s,1,Playback(goodbye)
same => n,Verbose(Not Allowed to call)
same => n,Hangup()
之后重新加载Asterisk:
asterisk -rvvvv
reload
下载phpagi库,在Asterisk控制台上运行以下命令
cd /var/lib/asterisk/agi-bin
git clone https://github.com/welltime/phpagi
然后在check_callerid.php
创建/var/lib/asterisk/agi-bin
脚本并授予其完整权限。您可以复制以下脚本
#!/usr/bin/php
<?php
global $agi;
require 'phpagi/phpagi.php';
$agi = new AGI();
$agi->answer();
$callerid = $argv[1];
$agi->verbose("CallerID is: $callerid");
$check_in_db = checkDB($callerid); //check caller allowed to do call
if($check_in_db==1){$agi->exec("Goto","welcome,s,1");} //allowed to do call, go to dial plan
else{$agi->exec("Goto","good_bye,s,1");} //not allowed to do call, go to dial plan
function checkDB($callerid){
//check here callerid allowed to do call or not
return 1;
}
?>
现在尝试从您已注册的软电话拨打任何10位数的电话号码,拨打电话将拨打exten => _XXXXXXXXXX,1,Answer()
拨号方案