【问题标题】:Asterisk callerid on outbound calls using Originate are showing unknow on agi_dnid使用 Originate 的出站呼叫上的星号 callerid 在 agi_dnid 上显示未知
【发布时间】:2019-07-07 09:33:41
【问题描述】:

我添加了一个自定义 PHP 文件来记录对我的 MySQL 数据库的所有出站调用。 这在我从任何分机拨号时有效,并记录来电显示和目的地号码等。

但是,当我运行一个单独的 PHP 脚本以从我的应用程序发起调用时。 来电显示和拨打的号码现在未知。

nano /var/lib/asterisk/agi-bin/logoutbound.php

#!/usr/bin/php -q
<?php
include("phpagi.php");
$agi = new AGI();


//$agi->noop("test 1");
$servername = "servername";
$username = "username";
$password = "pass";
$dbname = "database";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$mycallerid = $agi->request[agi_callerid];
$mycallername = $agi->request[agi_calleridname];
$phoneno = $agi->request['agi_dnid'];
$myuniid = $agi->request[agi_uniqueid];
$timestart = date('Y-m-d H-i-s');
$channel = $agi->request[agi_channel];
$extension = $agi->request[agi_extension];
$context = $agi->request[agi_context];


$sql = "INSERT INTO voip_outbound
(callerid,callername,uniid,starttime,phonenumber,channel,extension,context)
VALUES ('" . $mycallerid . "','$mycallername','$myuniid','$timestart','$phoneno','$channel','$extension','$context'$

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}


$conn->close();
?>

这个文件被调用 nano extensions_custom.conf

[macro-dialout-trunk-predial-hook]
exten => s,1,Noop(Custom outbound call)
exten => s,n,AGI(logoutbound.php)

所以当我拨出时,我的 MySQL 中会显示以下内容。这是正确的

Refid 30 + 32 显示从分机拨打的电话。 Refid 31 显示使用发起脚本进行的调用 - 见下文

<?php
error_reporting(0);
#ip address that asterisk is on.
$strHost = "127.0.0.1";
$strUser = "admin";#specify the asterisk manager username you want to login with
$strSecret = "managerpass";#specify the password for the above user
#specify the channel (extension) you want to receive the call requests with
#e.g. SIP/XXX, IAX2/XXXX, ZAP/XXXX, etc
# $strChannel = "SIP/100";
$strChannel = $_REQUEST['exten'];
$strContext = "from-internal";
#specify the amount of time you want to try calling the specified channel     before hangin up
$strWaitTime = "30";
#specify the priority you wish to place on making this call
$strPriority = "1";
#specify the maximum amount of retries
$strMaxRetry = "2";
$number=strtolower($_REQUEST['number']);
$pos=strpos ($number,"local");
if ($number == null) :
exit() ;  
endif ;
if ($pos===false) :
$errno=0 ;
$errstr=0 ;
$strCallerId = "$number";
#$strCallerId = "$strChannel";
$oSocket = fsockopen ("localhost", 5038, $errno, $errstr, 20);
if (!$oSocket) {
echo "$errstr ($errno)<br>\n";
} else {
fputs($oSocket, "Action: login\r\n");
fputs($oSocket, "Events: off\r\n");
fputs($oSocket, "Username: $strUser\r\n");
fputs($oSocket, "Secret: $strSecret\r\n\r\n");
fputs($oSocket, "Action: originate\r\n");
fputs($oSocket, "Channel: $strChannel\r\n");
fputs($oSocket, "WaitTime: $strWaitTime\r\n");
#fputs($oSocket, "CallerId: $strCallerId <$strCallerId>\r\n");
fputs($oSocket, "CallerId: $number\r\n");
fputs($oSocket, "Exten: $number\r\n");
fputs($oSocket, "Context: $strContext\r\n");
fputs($oSocket, "Priority: $strPriority\r\n\r\n");
fputs($oSocket, "Action: Logoff\r\n\r\n");
sleep(2);
fclose($oSocket);
} 
echo "Extension $strChannel should be calling $number." ;
else :
exit() ;
endif ;
?>

所以我的预期结果是显示拨打的号码而不是未知号码 我将如何解决这个问题以显示正确的信息?

也许我应该从另一个宏或其他东西中调用该文件。

感谢您的帮助

编辑:根据我的脚本更改为 loca 后在评论中更改。 因此,以 Local/1069 insead of PJSIP/ 发送到我的扩展我仍然在我的 mysql 中得到这个

【问题讨论】:

    标签: asterisk


    【解决方案1】:

    在您的示例中 callerid 不是未知的。

    来电显示名称未知。

    你可以试试

    Callerid: "name" <number>
    

    如果没有帮助,请使用本地频道和 Set(CALLERID(name)=

    关于 freepbx 报告中的 DST 参数 - 如果你想设置它,你可以使用 Local/num@ext-local。

    【讨论】:

    • 来电者姓名未知,我并不关心它。我想要的只是电话号码。但是,当我使用脚本时,电话号码也不知道。
    • 使用freepbx拨号方案
    • 我不明白您所说的使用免费 PBX 拨号方案是什么意思,请您详细说明
    • 你已经使用 Local/num@ext-local 而不是 SIP
    • 嗨,Artheops,对不起,我很愚蠢,但我真的不知道如何更改我的 PHP 脚本以发送格式为“Local/num@ext-local”的拨号命令。有没有机会你可以帮我做,拜托。不过我会继续努力的
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-16
    • 1970-01-01
    • 1970-01-01
    • 2021-08-22
    • 1970-01-01
    • 2018-01-02
    相关资源
    最近更新 更多