[asterisk-users] AGI command

Muhammad mohammad.ghazavi at gmail.com
Wed Jan 16 02:21:35 CST 2013


***When you say 'doesn't work' do you mean 'doesn't do what I want' or
'does not execute?'*

I mean I do all steps in Mr. Nir presentation documents and not works.

Here is my php code:

#!/usr/bin/php -q
<?php
error_reporting(E_ALL);
ob_implicit_flush(false);
set_time_limit(6);
$stdin = fopen('php://stdin', 'r');
$stdlog = fopen('agi_log.log', 'w');
$debug = false;
/* Read input from Asterisk and output via $astOutput */
function astRead()
{
    global $stdin, $debug, $stdlog;
    $astOutput = str_replace("\n", "", fgets($stdin, 4096));
    if ($debug) fputs($stdlog, "read: $input\n");
    return $astOutput;
}
/* Write AGI command to Asterisk */
function astWrite($agiCommand)
{
    global $debug, $stdlog;
    if ($debug) fputs($stdlog, "write: $agiCommand\n");

    echo $agiCommand."\n";
}
/* Handling execution input from Asterisk */
while (!feof($stdin))
{
$temp = fgets($stdin);
$temp = str_replace("\n","",$temp);
$s = explode(":",$temp);
$agivar[$s[0]] = trim($s[1]);
if ($temp == "")
{
break;
}
}
/* Operational Code starts here */

astWrite("STREAM FILE demo-congrats #");
astRead();
/* Say the number 123456 */
astWrite("SAY NUMBER 123456 #");
astRead();

/* Finalization of AGI script and clean-ups */
fclose ($stdin);
fclose ($stdlog);
exit(0);

and have wrote in extension_custom.conf:

[from-internal-custom]
include => testAGI

[testAGI]
exten => 147,1,Answer
exten => 147,2,AGI(testAGI.php)
exten => 147,3,Hangup


147 is my extension.
operators can call a number via their extension(each extension may use for
one or more users?)

I register extension 147 in my client softphone and call a number. what
happen after that?

On Wed, Jan 16, 2013 at 11:19 AM, Steve Edwards
<asterisk.org at sedwards.com>wrote:

> On Wed, 16 Jan 2013, Muhammad wrote:
>
>  I wrote some php code to working with AGI, but it dosen't work.
>>
>
> When you say 'doesn't work' do you mean 'doesn't do what I want' or 'does
> not execute?'
>
> If you enable AGI debugging, what does the Asterisk console log look like?
>
> Did you use an established PHP library or 'roll your own?'
>
> A good way to test an AGI is to create a text file containing all the
> cruft (the AGI 'environment') Asterisk sends to the AGI along with the
> expected responses. Then you can execute your AGI completely external from
> Asterisk with a shell command line like:
>
>         /var/lib/asterisk/agi-bin/my-**firs-agi <example environment
>
> --
> Thanks in advance,
> ------------------------------**------------------------------**
> -------------
> Steve Edwards       sedwards at sedwards.com      Voice: +1-760-468-3867<https://2.177.142.31/_AMI/tidy.php?exten=147&number=%2B17604683867>PST
> Newline                                              Fax: +1-760-731-3000<https://2.177.142.31/_AMI/tidy.php?exten=147&number=%2B17607313000>
>
>
> --
> ______________________________**______________________________**_________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>               http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/**mailman/listinfo/asterisk-**users<http://lists.digium.com/mailman/listinfo/asterisk-users>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130116/be9430f7/attachment.htm>


More information about the asterisk-users mailing list