Phpagi and passing variable to and from asterisk

I am at my witts end…i have used the phpagi and did most of the functions…but can not get the most important ones to work. I need get_variable to work…please someone respond with a sample and not just a phrase like “go look here”. my issues are:

  1. can not get_variable to bring in the value of $foo.
  2. i can not use echo to display the value, how can i display it ?
  3. it shows up as an array in the database, why? how can i print an array value?

I am in much pain…any help would be appriciated.

this is the sample that i am talking about please someone --fix it --please?

i have an extension.conf file :

exten => 298,1,NoOp(${foo})
exten => 298,2,Set(foo=1212)
exten => 298,3,Answer
exten => 298,4,AGI(input9.php|${foo})
exten => 298,5,Hangup

I have an input9.php file that looks like this:

<?php set_time_limit(30); require('phpagi.php'); $agi = new AGI(); $agi->answer(); $fooo = $agi->get_variable($foo); $agi->text2wav("You entered " . $fooo); // echo $fooo ; // mysql stuff $dbhost = "localhost"; $dbuser = "root"; $dbname = "asterisk"; $dbpass = "nd"; // connect to db mysql_connect($dbhost, $dbuser, $dbpass) or die ("Failed to connect to the database!"); mysql_select_db($dbname) or die(mysql_error()); $query = "insert into pbook values ('$mynum', '$fooo');"; $result = mysql_query($query) or die(mysql_error()); $agi->text2wav('Goodbye'); $agi->hangup(); ?>

I don’t know phpagi. But I highly doubt if the above should work, because phpagi thinks you are trying to get the value of an Asterisk channel variable named 0 (or any default value PHP assigns to an undefined variable).


instead. (This way, you don’t have to fool phpagi with the extra ‘o’ :wink:

Just for the fun of it, you can also do

$foo = 'foo'; $fooo = $agi->get_variable($foo);

As well as the above, I think get_variable() returns an array.

I use this in my script:

$result = $agi->get_variable('STATUS'); $status = $result['data'];

And part of extensions.conf

[code]exten => t,1,SetGlobalVar(STATUS=timeout)
exten => t,2,Hangup

exten => h,1,DeadAGI,ack.php


exten => check,n,AGI(verify.php|${CALLERID(num)})



<?php $NUMBER = $argv[1]; ... [/code[[/code]