STREAM FILE or GET DATA problem

Hello

I have tried coding AGI script with Php and i can dial an extensions and im redirected to AGI sript. my goal is to test the SAY NUMBER and STREAM FILE function. talking about SAY NUMBER has no problem as i can hear the assigned number being announce. but when it comes to STREAM FILE i hear nothing it seems that file is not being played. here is my code…

#!/usr/bin/php -q

<?php $numbertosay = 2345; # don't let this script run for more than 60 seconds set_time_limit(60); # turn off output buffering ob_implicit_flush(false); # turn off error reporting, as it will most likely interfere with # the AGI interface error_reporting(0); # create file handles if needed if (!defined('STDIN')) { define('STDIN', fopen('php://stdin', 'r')); } if (!defined('STDOUT')) { define('STDOUT', fopen('php://stdout', 'w')); } if (!defined('STDERR')) { define('STDERR', fopen('php://stderr', 'w')); } # retrieve all AGI variables from Asterisk while (!feof(STDIN)) { $temp = trim(fgets(STDIN,4096)); if (($temp == "") || ($temp == "\n")) { break; } $s = split(":",$temp); $name = str_replace("agi_","",$s[0]); $agi[$name] = trim($s[1]); } # print all AGI variables for debugging purposes foreach($agi as $key=>$value) { fwrite(STDERR,"-- $key = $value\n"); fflush(STDERR); } # print all AGI variables for debugging purposes foreach($agi as $key=>$value) { fwrite(STDERR,"-- $key = $value\n"); fflush(STDERR); } fwrite(STDOUT,"SAY NUMBER $numbertosay \"\"n"); flush(STDOUT); fwrite(STDOUT,"STREAM FILE account-balance-is \"\"n"); fflush(STDOUT); ?>

when i put comments before
fwrite(STDOUT,"STREAM FILE account-balance-is "“n”);
and
fflush(STDOUT);
i can hear the number 2345 is being announced but when i remove the comments i hear nothing,
likewise when i put comments before
fwrite(STDOUT,"SAY NUMBER $numbertosay "“n”);
and
flush(STDOUT);
(wanted to hear the STREAM FILE) still hear nothing, the same error before in my xlite phone “603 Declined”

in my extensions.conf

exten => 1000,1,agi,salary.php
exten => 1000,2,Hangup

and in my Asterisk CLI i’ve generated this debug when there were no comments in SAY NUMBER and STREAM FILE lines…

Connected to Asterisk 1.2.10 currently running on rendezvous (pid = 2437)
AGI Tx >> agi_request: salary.php
AGI Tx >> agi_channel: SIP/anton-081f52f8
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1158824339.533
AGI Tx >> agi_callerid: anton
AGI Tx >> agi_calleridname: anton
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1000
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: internal
AGI Tx >> agi_extension: 1000
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << SAY NUMBER 2345 ""nSTREAM FILE account-balance-is ""n
AGI Tx >> 520-Invalid command syntax. Proper usage follows:
AGI Tx >> Usage: SAY NUMBER
Say a given number, returning early if any of the given DTMF digits
are received on the channel. Returns 0 if playback completes without a digit
being pressed, or the ASCII numerical value of the digit if one was pressed or
-1 on error/hangup.
AGI Tx >> 520 End of proper usage.

please help make clear things here!
is the "STREAM FILE escaped char"
where is the filename.gsm in the
/usr/src/asterisk/asterisk-sounds-1.2.1/sounds/
or is in the
/var/lib/asterisk/sounds/
or Asterisk read the = “account-balance-is” and announced it to caller?

hope to hear from you pals

Thanks

i also tried to used “GET DATA” function but still it doesnt work.
it seem that it ignore whenenver php or asteisk see this functions such as “GET DATA” and “STREAM FILE” and response to the caller with busy tone or
603 Declined error.

Any help for today?

[quote]fwrite(STDOUT,"SAY NUMBER $numbertosay "“n”);
flush(STDOUT);
fwrite(STDOUT,"STREAM FILE account-balance-is "“n”);
fflush(STDOUT); [/quote]

I can see flush instead of fflush.
Why don’t you use phpagi. It shouldl reduce such typos.

yep i figure it out and now i hear the "eneter passwaord"
but it doesnt wait fot time to end
and when ir remove the sleep() below i hear nothing
.
.
.
fwrite(STDOUT,“ANSWER “”\n”);
fflush(STDOUT);
fwrite(STDOUT,“GET DATA enter-password 15000 6 “”\n”);
fflush(STDOUT);
sleep(3);
.
.

my CLI result is this …

Connected to Asterisk 1.2.10 currently running on rendezvous (pid = 2441)
AGI Tx >> agi_request: salary.php
AGI Tx >> agi_channel: SIP/anton-081b5f48
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1158915474.134
AGI Tx >> agi_callerid: anton
AGI Tx >> agi_calleridname: anton
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1000
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: internal
AGI Tx >> agi_extension: 1000
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << ANSWER ""
AGI Tx >> 200 result=0
AGI Rx << GET DATA enter-password 15000 6 ""
rendezvous*CLI>

@vinod.vijayan

yah! about phpAGI, i spend much time of googling about how to install/setup
or how to place it (the phpAGI Class) in my aseteisk server so i could call and use it in my php script.

please if you have time in telling me the step-by-step of configuring phpAGI,
please teach me in very details as i found this url eder.us/projects/phpagi/ a little bit hard to figure out (im affraid to install something and mess my system ). thus i temporarily use and pursue my script in that style w/o phpAGI.

i have install my php with socket enable with Php CLI version 4…13.10-16

please help

Thank you very much in advance

For installing simply copy the “phpagi.php” file and copy it to the agi-bin folder.
Include this file in the agi file you are creating.
After including it object of AGI class can be instantiated for calling its various methods.

e.g.

     $agi = new AGI();
     $agi->answer();
     $agi->stream_file('vm-goodbye');
     $agi->hangup();

Refer for more info:
phpagi.sourceforge.net/phpagi2/docs/

so what about the /etc/asterisk/phpagi.conf which is mentioned all the time in tutorials? how to figure it out and what is that conf for? when it can be used?

hope you have time again

Thanks

my phpagi.conf file contains a section for festival, and nothing else. the contents (or lack of) don’t appear to stop AGI working.

[quote=“kerberos”]Hello

I have tried coding AGI script with Php and i can dial an extensions and im redirected to AGI sript. my goal is to test the SAY NUMBER and STREAM FILE function. talking about SAY NUMBER has no problem as i can hear the assigned number being announce. but when it comes to STREAM FILE i hear nothing it seems that file is not being played. here is my code…

#!/usr/bin/php -q

<?php $numbertosay = 2345; # don't let this script run for more than 60 seconds set_time_limit(60); # turn off output buffering ob_implicit_flush(false); # turn off error reporting, as it will most likely interfere with # the AGI interface error_reporting(0); # create file handles if needed if (!defined('STDIN')) { define('STDIN', fopen('php://stdin', 'r')); } if (!defined('STDOUT')) { define('STDOUT', fopen('php://stdout', 'w')); } if (!defined('STDERR')) { define('STDERR', fopen('php://stderr', 'w')); } # retrieve all AGI variables from Asterisk while (!feof(STDIN)) { $temp = trim(fgets(STDIN,4096)); if (($temp == "") || ($temp == "\n")) { break; } $s = split(":",$temp); $name = str_replace("agi_","",$s[0]); $agi[$name] = trim($s[1]); } # print all AGI variables for debugging purposes foreach($agi as $key=>$value) { fwrite(STDERR,"-- $key = $value\n"); fflush(STDERR); } # print all AGI variables for debugging purposes foreach($agi as $key=>$value) { fwrite(STDERR,"-- $key = $value\n"); fflush(STDERR); } fwrite(STDOUT,"SAY NUMBER $numbertosay ""n"); flush(STDOUT); fwrite(STDOUT,"STREAM FILE account-balance-is ""n"); fflush(STDOUT); ?>

when i put comments before
fwrite(STDOUT,"STREAM FILE account-balance-is "“n”);
and
fflush(STDOUT);
i can hear the number 2345 is being announced but when i remove the comments i hear nothing,
likewise when i put comments before
fwrite(STDOUT,"SAY NUMBER $numbertosay "“n”);
and
flush(STDOUT);
(wanted to hear the STREAM FILE) still hear nothing, the same error before in my xlite phone “603 Declined”

in my extensions.conf

exten => 1000,1,agi,salary.php
exten => 1000,2,Hangup

and in my Asterisk CLI i’ve generated this debug when there were no comments in SAY NUMBER and STREAM FILE lines…

Connected to Asterisk 1.2.10 currently running on rendezvous (pid = 2437)
AGI Tx >> agi_request: salary.php
AGI Tx >> agi_channel: SIP/anton-081f52f8
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1158824339.533
AGI Tx >> agi_callerid: anton
AGI Tx >> agi_calleridname: anton
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1000
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: internal
AGI Tx >> agi_extension: 1000
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << SAY NUMBER 2345 ""nSTREAM FILE account-balance-is ""n
AGI Tx >> 520-Invalid command syntax. Proper usage follows:
AGI Tx >> Usage: SAY NUMBER
Say a given number, returning early if any of the given DTMF digits
are received on the channel. Returns 0 if playback completes without a digit
being pressed, or the ASCII numerical value of the digit if one was pressed or
-1 on error/hangup.
AGI Tx >> 520 End of proper usage.

please help make clear things here!
is the “STREAM FILE escaped char”
where is the filename.gsm in the
/usr/src/asterisk/asterisk-sounds-1.2.1/sounds/
or is in the
/var/lib/asterisk/sounds/
or Asterisk read the = “account-balance-is” and announced it to caller?

hope to hear from you pals

Thanks[/quote]