[Asterisk-Users] Important note for AGI with PHP newbies

Nathan Alpert asterisk at demicrosystems.com
Thu Jul 15 14:35:48 MST 2004


I say this note is important only because I (a AGI PHP newbie) was
tormented by this problem for many an hour, even though I'm sure it's
documented somewhere or obvious to more experienced users.

So as I was experimenting with AGI in PHP scripting I was baffled by why
Asterisk was properly receiving AGI commands written to stdout but
always returning "510 invalid command" to the stdin. For example, doing
a verbose command would properly show the message in the asterisk CLI
but it would return "510 invalid." Also, commands like GET DATA and GET
DIGIT would not work at all, even though the CLI would report "Playing
file my-file."

After spending literally hours fumbling around with different buffer
flushing schemes in PHP to no avail (I already knew I was doing the
flushing properly anyway) and sending an email to this email list, I
finally wrote a script that actually returned the proper values in
stdin.

The thing that fixed it was putting the "-q" argument in the
"#!/usr/local/php -q" thing that you put on the first line of your
script file. Apparently this argument tells PHP to supress HTML headers
or something according to the documentation. I'm still not %100 sure why
this would make a difference, but it does!

Everybody is probably already aware of this, but I wasn't, so I hope
this helps any other newbie who had the same problem.

-nate alpert




More information about the asterisk-users mailing list