0

I want to make simple IVR using php in Asterisk. when i run php program individually , it works without any problem. but when i call it by AGI command in the Asterisk it does not works. this is my php file :

#!/usr/bin/php -q
<?
 set_time_limit(30);
 require('phpagi.php');
 $agi = new AGI();
 $agi->answer();
 $file = '/var/www/html/test.txt';
 $current = file_get_contents($file);
 $current .= "Test\n";
 file_put_contents($file, $current);
 $agi->say_digits(1234);
 $agi->hangup();
 ?>

and this is Dialplan :

[testphp]
exten => 6565,1,Answer 
exten => 6565 2,Playback(Hello-World)
exten => 6565,3,AGI(testphp.php) 
exten => 6565 4,Playback(Hello-World)
exten => 6565,5,Hangup 

when i call 6565 by my phone , it only plays twice "Hello World" message! php file permission is excutable.

I have installed Elastix(Asterisk) in VirtualBox.

What am I doing wrong?

please help.

  • did u see on the CLI if its generating any error ? The best way to debug an AGI to put the features step by step. say you first test if it executes 'say_digit'... !! – Arfeen May 31 '12 at 06:08
  • also check the location of the PHP script you have created. – Arfeen May 31 '12 at 06:31
  • php script location is : `/var/lib/asterisk/agi-bin/`. but how to debug or test AGI and say_digit? –  May 31 '12 at 08:30
  • first do nothin in AGI except echoing some output(verbose), so you can have an idea that the script is running and executing and gradually add your other things. – Arfeen May 31 '12 at 09:21
  • could you do "set core verbose 99" in the asterisk cli, then run your agi application (by issuing a call) and capture and post the console output here? – marcelog May 31 '12 at 17:24
  • 1
    `set agi debug on` will give you debugging for your agi script – Mbrevda Jun 03 '12 at 05:43

1 Answers1

0

Do follwoing:

1) stop asterisk

asterisk -rx "core stop now"

2) start it in ssh console

asterisk -vvvgc

3) enable asterisk AGI debug

agi set debug on

you will see error in your script. also check that selinux is off

arheops
  • 15,544
  • 1
  • 21
  • 27