繁体   English   中英

使用Originate的出站呼叫上的星号callerid在agi_dnid上显示未知

[英]Asterisk callerid on outbound calls using Originate are showing unknow on agi_dnid

我添加了一个自定义PHP文件,以将所有出站呼叫记录到我的MySQL数据库中。 当我从任何分机拨号并记录呼叫者ID和目的地号码等时,此方法有效。

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

纳米/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中得到以下内容。 而且这是正确的

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后,注释已更改。 所以发送到我的扩展名作为PJSIP / Local / 1069 insead /我仍然在我的mysql中得到它

在此处输入图片说明

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

来电显示NAME未知。

您可以尝试使用

Callerid: "name" <number>

如果没有帮助,请使用本地渠道并设置(CALLERID(name)=

关于freepbx报表中的DST参数-如果要设置,请使用Local / num @ ext-local。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM