[asterisk-users] Get dialed numbers in AGI

Anton Frolov afng072 at frols.com
Wed Jan 10 12:29:52 MST 2007


hi

I never really programmed in PHP, I use Perl for my purposes.
I found a good AGI library for Perl and is happy with it. It allows me to call
functions instead of parsing the input.
While looking for my library, I saw at least one for PHP. So why not to use it?

In Perl it looks like:
  my %agiArgs = $AGI->ReadParse();
  my $callerNum = $agiArgs{"callerid"}; // Got the caller id
  $retval = $AGI->exec('Dial', $CHANNEL."|".$CALL_OPTIONS); // Placing a call

it's so simple...
(and you have the error checking "built in"!)

I'm sure you could find such a library for PHP as well!

AF.


Ralph Liebessohn wrote:
> On 1/10/07, *Yuan LIU* <yliu11 at hotmail.com <mailto:yliu11 at hotmail.com>>
> wrote:
> 
>     Then there must be an error somewhere.  The variable READ() in Asterisk
>     should be usable.  Should be able to use SayDigits() to play it back
>     - or no
>     value is read.
> 
>     Yuan Liu
> 
> 
>  Hi Yuan and Anton,
> 
> Let's put here all AGI for test:
> 
> #!/usr/bin/php -q
> <?php
> ob_implicit_flush(false);
> error_reporting(0);
> $stdin = fopen( 'php://stdin', 'r' );
> 
> if (!defined('STDIN'))
> {
>         define('STDIN',fopen('php://stdin','r'));
> }
> if (!defined('STDOUT'))
> {
>         define('STDOUT',fopen('php://stdout','r'));
> }
> if (!defined('STDERR'))
> {
>         define('STERR',fopen('php://stderr','r'));
> }
> 
> while(!feof($stdin))
> {
>         $temp=trim(fgets(STDIN,4096));
>         if (($temp=="") || ($temp="\n"))
>         {
>                 break;
>         }
>         $s=split(":",$temp);
>         $nome=str_subst("agi_","",$s[0]);
>         $agi[$nome]=trim($s[1]);
> }
> 
> foreach($agi as $chave=>$valor)
> {
>         fwrite(STDERR,"--$chave=$valor\n");
>         fflush(STDERR);
> }
> $my_var="123";
> fflush(STDERR);
> fwrite(STDERR,"Just testing\"\"\n");
> fflush(STDERR);
> fwrite(STDOUT,"exec read
> my_var|//usr/share/asterisk/sounds/please-wait-connect-oncall-eng|5|||15
> \n");
> fwrite(STDOUT,"exec saydigits ${my_var} \n");
> fflush(STDOUT);
> 
> $conn=odbc_connect('MSSQL', 'asterisk', '123456');
> $query = odbc_exec($conn, "INSERT INTO usuario(nome) VALUES('$my_var')");
> ?>
> 
> If I not startup $my_var="123"; Saydigits receives a NULL as options.
> And so nothing was inserted into db.
> I tried to use WAIT FOR DIGIT but it makes no sense, asterisk passed
> through it directly like Joel Lansden <Joel AT digitalparadise DOT net>
> reported on 9/14/06.
> Is there another function or way to test it or I must try in another
> asterisk box?
> 
> -- 
> Ralph Liebessohn
> ICQ: 74835911
> Skype: liebessohn
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
> 
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users


More information about the asterisk-users mailing list