Problema with php agi


I need your help because i have a problema with the library “phpagi”

for example i have “myagi.php” in this file, i have

<?php include(phpagi.php); $agi = new AGI(); $agi->answer(); $agi->hangup(); ?>

But when i do “php myagi.php” on the CLI
I have these errors

PHP NOTICE: Undefined index: PATH in /var/lib/asterisk/agi-bin/phpagi.php on line 1693

Sorry for my english!!! Thanks!!

Privet :wink:
It’s ok. such script can’t run from console. You must start it from dialplan.
And of course you must place php-agi files into default asterisk agi folder.
In your case it is: /var/lib/asterisk/agi-bin/

Ah!!! thanks!!, but i have other problem with that, for example

in asterisk I active “agi set debug on”

and I dial to my agi, i can see how my agi is intrepreted with rx and rx but at the final
I see the error

error 510 invalid or unknown command

So, post here yours phpagi config, script and dialplan command.
I may be able to see what’s the problem.

Sure!!, only i want to know, when you say “phpagi config” are you refer to the phpagi.php???

I’m not in my home, but when I arrive I will post it all!!, but i want to know what means “phpagi conf”

Sorry, i am new with the agi

thanks so much

Well, i have found something for you, may be this can help:
Look at yours php.ini option: variables_order, it must be variables_order = “EGPCS” if you need to kill error about PATH index. But i think that you have some wrong configurations with phpagi and it can’t use standart variable for command path and trying to use $_ENV.

I mean /etc/asterisk/phpagi.conf

The error is clear error 510 invalid or unknown command phpagi classis very easy to use but it requires basic knowlege of php and asterisk.

make sure you have invoked the the correct command or you have the right syntax on your php agi script

!/usr/local/bin/php -q
PHP Notice: Use of undefined constant phpagi - assumed ‘phpagi’ in /var/lib/asterisk/ag-bin/SMSSMS.php on line 4
PHP Notice: Use of undefined constant php - assumed ‘php’ in /var/lib/asterisk/ag-bin/SMSSMS.php on line 4
PHP Warning: require(phpagiphp): failed to open stream: No such file or directory in /var/lib/asterisk/ag-bin/SMSSMS.php on line 4
PHP Fatal error: require(): Failed opening required ‘phpagiphp’ (include_path=’.:/usr/share/php’) in /var/lib/asterisk/ag-bin/SMSSMS.php on line 4

I got this error when i hit api using curl in agi asterisk
!/usr/local/bin/php -q

<?php set_time_limit(0); require(phpagi.php); $agi = new AGI(); $agi->answer(); $request_url=" team&time=1236299296 (Time In seconds from 1 Jan 1970)rpt=1"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); ?>

Where phpagi.php is situated on your disk?

exten => 1234,1, Answer();
exten => 1234,n, Playback(/var/lib/asterisk/sounds/custom/tt-monkeys);
exten => 1234,n, Wait(0.5)
exten => 1234,n, Dial(SIP/${EXTEN},0.5);
exten => 1234,n, h,1,AGI(var/lib/asterisk/agi-bin/SMSSMS.php);
exten => 1234,n, Hangup();

I want sound is played only for 30 sec after that call will be hangup , then agi script will be run , but when I call to 1234 sound nplayed continue and and not automaticlly hangup and not even agi script will work . Please help me out

That’s not a valid line,
It should be
exten => h,1,AGI(var/lib/asterisk/agi-bin/SMSSMS.php)

you need the leading / if you are specifying the full path.

If you are using a relative path you can omit it.

True, I didn’t notice that when replying to OP

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.