简体   繁体   English

星号agi无法正常工作

[英]Asterisk agi not working

I'm having the simple AGI script, when incoming call is answered run script. 我有一个简单的AGI脚本,当接听来电时运行脚本。 But does not working. 但是不起作用。 How can i run my script correctly? 如何正确运行脚本?

By the way sorry for my english. 对不起,我的英语。

Here's code: 这是代码:

extensions_additional.conf extensions_additional.conf

[macro-auto-blkvm]

include => macro-auto-blkvm-custom

exten => s,1,Set(__MACRO_RESULT=)    
exten => s,n,DBDel(${BLKVM_OVERRIDE})

exten => s,n,AGI(call-answered.agi,${CALLERID(ANI)},${CHANNEL})   

call-answered.php: call-answered.php:

#!/usr/bin/php -q
<?php
include("phpagi.php");
$agi = new AGI();
$agi->verbose("------------------------------------------");
$ani = $agi->request['agi_callerid'];
$agi->noop("My CalleID: <<<<<<<=".$ani);

$user = 'root';
$pass = 'eLaStIx.2oo7';
$db = new PDO('mysql:host=localhost;dbname=call', $user, $pass);

$query = $db->prepare("INSERT INTO deneme SET
gsm = ?,
agent = ?");
$insert = $query->execute(array("123123", "213123"));

Console output: 控制台输出:

-- SIP/103-0000000e answered Local/103@from-internal-3556,2
-- Executing [s@macro-auto-blkvm:1] Set("SIP/103-0000000e", "__MACRO_RESULT=") in new stack
-- Executing [s@macro-auto-blkvm:2] Set("SIP/103-0000000e", "CFIGNORE=") in new stack
-- Executing [s@macro-auto-blkvm:3] Set("SIP/103-0000000e", "MASTER_CHANNEL(CFIGNORE)=") in new stack
-- Executing [s@macro-auto-blkvm:4] Set("SIP/103-0000000e", "FORWARD_CONTEXT=from-internal") in new stack
-- Executing [s@macro-auto-blkvm:5] Set("SIP/103-0000000e", "MASTER_CHANNEL(FORWARD_CONTEXT)=from-internal") in new stack
-- Executing [s@macro-auto-blkvm:6] Macro("SIP/103-0000000e", "blkvm-clr|") in new stack
-- Executing [s@macro-auto-blkvm:7] AGI("SIP/103-0000000e", "call-answered.agi|*******|SIP/103-0000000e") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/call-answered.agi
AGI Tx >> agi_request: call-answered.agi
AGI Tx >> agi_channel: SIP/103-0000000e
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1481798039.22
AGI Tx >> agi_callerid: 103
AGI Tx >> agi_calleridname: unknown
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: unknown
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: macro-auto-blkvm
AGI Tx >> agi_extension: s
AGI Tx >> agi_priority: 7
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
-- AGI Script call-answered.agi completed, returning 0
-- Executing [s@macro-auto-blkvm:8] ExecIf("SIP/103-0000000e", "0?Set(MASTER_CHANNEL(CONNECTEDLINE(num))=103)") in new stack
== Spawn extension (macro-auto-blkvm, s, 8) exited non-zero on 'SIP/103-0000000e' in macro 'auto-blkvm'
-- Local/103@from-internal-3556,1 answered SIP/103-0000000d
-- Stopped music on hold on SIP/**-0000000d

Thanks 谢谢

Are you sure you named your file call-answered.php ? 您确定将文件命名为call-answered.php吗? You refer to it in dialplan as call-answered.agi , which looks inconsistent. 您在Dialplan中将其称为call-answered.agi ,它看起来不一致。 Try changing the dialplan to call-answered.php . 尝试将拨号计划更改为call-answered.php

Check that the .php files have the read and execute file permissions. 检查.php文件是否具有读取和执行文件权限。 Run chmod 755 /var/lib/asterisk/agi-bin/*.php to set that. 运行chmod 755 /var/lib/asterisk/agi-bin/*.php进行设置。

Also check that they're located in the correct directory (default is /var/lib/asterisk/agi-bin), or specify the full path in your dialplan. 还要检查它们是否位于正确的目录中(默认目录为/ var / lib / asterisk / agi-bin),或在拨号计划中指定完整路径。 Throw it in quotes to be safe: 为了安全起见,将其用引号引起来:

exten => s,n,AGI('/var/lib/asterisk/agi-bin/call-answered.php',${CALLERID(ANI)},${CHANNEL})

You can find more help at the Official AGI Docs , or at the Voip Info (unofficial) page . 您可以在AGI官方文档Voip信息(非官方)页面上找到更多帮助。

Edit: You can also try running your script directly from the PHP cli by running: 编辑:您也可以尝试通过运行以下命令直接从PHP cli运行脚本:

php /var/lib/asterisk/agi-bin/call-answered.php

Press enter repeatedly to simulate communications with Asterisk. 反复按Enter以模拟与Asterisk的通信。 If there are any permissions or script errors you will usually see those in this cli session. 如果有任何权限或脚本错误,通常会在此cli会话中看到这些权限或脚本错误。 If that still doesn't work, use php's error_log() command to write some useful info to the log so you can tell if your script is running at all. 如果仍然不起作用,请使用php的error_log()命令将一些有用的信息写入日志,以便您可以判断脚本是否正在运行。

That mean you have syntax error or permission issue in your script. 这意味着您的脚本中存在语法错误或权限问题。 Or maybe just no script at path. 或者,也许路径上没有脚本。

ie it not respond at all. 即它根本不响应。

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

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