Help finding FUNCTIONAL AGI Hello World?

Would it be possible for someone to point me in the direction of a AGI script in PHP that does a simple Hello World type functionality and that actually WORKS?

I have been messing with … g-with-php the Hello World script and after getting the script to actually function without error, All that happens if Asterisk hangs with the script running.

I am using Asterisk 1.6 on CentOS. I run asterisk -gvvvvvvvc, and I see the incoming call, I see the extension selected, and I see Asterisk start the php script, but nothing ever happens after that. From listening to the dialed extension I get nothing but silence, and from the console it just sites there until I hangup the extension at which time it console shows the script completing…

I am learning Asterisk, and PHP all at the same time, and I am taking baby steps to learn each step of the way to expand as I go.

take a look here:

And see the examples.

That’s not what I am looking for… I am not wanting to add more complications and software on top of the system… For now I am wanting to keep things as simple as possible and take one step at a time.

Just looking for a script that causes Asterisk to do something like play HelloWorld or anything when called:
exten => 999,n,agi(HelloWorld.php)

I’ll take that and work from there for the next step

To me Navaismo is right, the script will be simpler if you use the phpagi class, worth try.


Marco Bruni

What I was looking for was simplicity, literally something as simple as fprintf(“Hello World”); The reason was two fold, since I am learning both PHP and Asterisk at the same time, the simplicity allows me to minimize the sources of bugs that cause it not to work.

I found what I was looking for:

[i]#!/usr/bin/php -q

<?php $stdin = fopen('php://stdin','r'); $stdout = fopen('php://stdout','w'); $stdlog = fopen('agi.log','w'); fputs($stdout,"SAY DIGITS 4321 '79#' \n"); fflush($stdout); exit; ?>


By getting this I was able to confirm that my AGI call in extensions.conf was correct, and that the interface worked. Next come getting the Asterisk variables that were passed along and to also begin getting a standardized read/write function setup, so here is what I have now:

[i]#!/usr/bin/php -q

<?php $stdin = fopen('php://stdin','r'); $stdout = fopen('php://stdout','w'); $stdlog = fopen('agi.log','w'); while (!feof($stdin)) { $temp = fgets($stdin); $temp = str_replace("\n","",$temp); $s = explode(":",$temp); $agivars[$s[0]] = trim($temp); if (($temp == "") || ($temp == "\n")) {break;} } write("SAY DIGITS 4321 '79#' \n"); exit; function write($line) { global $stdout, $stdin, $stdlog; fputs($stdout,$line); fflush($stdout); } ?>


I still have a ways to go before this has much use, but as a learning process I believe in taking baby steps, and looking back and seeing the ground that I have covered. Its always been the process that has worked for me in learning new languages. It’s not often that I have needed to learn two languages concurrently though.

Thanks for everyone’s input, I will eventually get to those other pages and methods.