[asterisk-users] How to pass variable back and forth from dialplan to php file?

bruce bruce bruceb444 at gmail.com
Mon Jun 14 16:17:44 CDT 2010


Hi again,

So, I have this but NoOp shows a random SIP info value rather then the one
passed to it. Just to test, I am sending $didin as argument to test.php and
then expect it back as $didgot back into dialplan. But it seems that either
send or receive has problem because no matter what I put as the NoOp in _x,4
it all comes back the same as SIP channel info.

*[custom-phpagi]*
*exten => _x.,1,Set(didin=${EXTEN})*
*exten => _x.,2,NoOp(${didin}*
*exten => _x.,3,deadAGI(test.agi,${didin})*
*exten => _x.,4,NoOp(${didgot})*
*exten => _x.,5,Hangup()*

*/var/lib/asterisk/agi-lib/test.agi:*

#!/usr/bin/php -q
<?php
set_time_limit(30);
require('phpagi/phpagi.php');

$didgot = $argv[1];

$agi = new AGI();

$agi->get_variable("didgot", $didgot);      /// both of these don't seem to
send didgot back to dialplan
$agi->set_variable("didgot", $didgot);      /// both of these don't seem to
send didgot back to dialplan


exit(0);
?>

Thanks,
Bruce


On Mon, Jun 14, 2010 at 2:15 PM, Carlos Chavez <cursor at telecomabmex.com>wrote:

> On Mon, 2010-06-14 at 13:41 -0400, bruce bruce wrote:
> > Hi Carlso,
> >
> >
> > Thanks for the input. I have done this in php and am not familiar with
> > phpagi.
> > So, there is absolutely no way to temporarily solve this problem by
> > getting the value back from php file?
> >
> >
> > Wondering if it would require a lot of work to change the php file to
> > phpagi?
> > Thanks,
> > Bruce
> >
>         Here is an example:
>
> exten => _x.,1,AGI(sample.agi)
> exten => _x.,n,NoOp(${var})
>
> sample.agi:
>
> #!/usr/bin/php -q
> <?php
> set_time_limit(30);
> require('phpagi/phpagi.php');
> $agi = new AGI();
> $exten = $agi->request['agi_extension']; //Dialed extension
> // the result is stored in $exten
> // do something with your data
> $agi->set_variable("var", $result);
> $agi->verbose("The result was: $result", 3);
> ?>
>
>        You can even send parameters to the AGI via the command line like:
>
> exten => _x.,1,AGI(sample.agi,param1,param2) //Use comma for 1.6 or |
> for 1.4 or below
>
>        And access them via $argv[1], $argv[2] is there is some extra
> information that you cannot get via the AGI variables.
>
> --
> Telecomunicaciones Abiertas de México S.A. de C.V.
> Carlos Chávez Prats
> Director de Tecnología
> +52-55-91169161 ext 2001
>
> --
> _____________________________________________________________________
> -- 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100614/1a21b0a9/attachment.htm 


More information about the asterisk-users mailing list