[SOLVED] Trying to pass Asterisk variables to a PHP script

I’m only 3 days old to Asterisk and I’m having great difficulty passing Asterisk variables (EG - callerid) to a PHP script. I’m trying to a very basic exercise of dialing a VoIP number and having a PHP script run which inserts the caller ID into a MySQL database.

I have read quite a few tutorials but none seem to give a straight example of passing a variable to a PHP script and being able to read that variable in the PHP script.

So here’s what I’m using:

exten => 101,1,Answer()
exten => 101,2,AGI(test.php|${agi_calleridname})
exten => 101,4,Hangup()

#!/usr/bin/php -q

<?php $fh = fopen("test.txt", "a+"); foreach($_REQUEST as $key => $val) fwrite($fh, "Key: ".$key." Val: ".$val."\n\n") ?>

The script is a+x chmodded and if I execute the script from a bash shell manually the script will insert, if I manually put an array element into $_POST or $_GET.

I have ran ‘asterisk -cr’ from the command line and I can’t see any errors regarding the AGI.

Any help welcome,

So what was the fix?! :question:

He doesnt specify what version he is using, but i assume his problem is:

$agi_calleridname which should be

${CALLERID(name)} or ${CALLERID(num)} depending on your needs.