[asterisk-users] PHP/AGI/SetVar Issue

Philipp Kempgen philipp.kempgen at amooma.de
Sat Jun 6 11:26:25 CDT 2009


Steve Edwards schrieb:

> If I follow the protocol:
> 
>          printf("STREAM FILE \"hit\" \"\"\n");
>          fflush(stdout);
>          fgets(response, sizeof(response), stdin);
> 
>          printf("STREAM FILE \"hit\" \"\"\n");
>          fflush(stdout);
>          fgets(response, sizeof(response), stdin);

> it works everywhere, every time.

PHP:

# enable implicit flushing of the output buffer.
# required for CentOS/RHEL because on that platform the php
# binary is php-cgi (which is wrong) instead of php-cli so
# fFlush(STDOUT) is not available
# (http://bugs.centos.org/view.php?id=1633)
ini_set('implicit_flush', 1);
ob_implicit_flush(1);

echo 'STREAM FILE "hit"' ,"\n";
//fFlush(STDOUT);
while (fgetc(STDIN) !== false) {}  // read (and ignore) STDIN

echo 'STREAM FILE "hit"' ,"\n";
//fFlush(STDOUT);
while (fgetc(STDIN) !== false) {}  // read (and ignore) STDIN

> As I and others have suggested, stand on the shoulders of others -- please 
> use an established library. You will save time and hair. And your code 
> will be easier to write and maintain:
> 
>  	agi_stream_file("hit", "");
>  	agi_stream_file("hit", "");

True, if you're able to find a library which properly escapes
strings etc. for the language of your choice.


    Philipp Kempgen
-- 
AMOOMA GmbH - Bachstr. 126 - 56566 Neuwied  ->  http://www.amooma.de
Geschäftsführer: Stefan Wintermeyer, Handelsregister: Neuwied B14998
Asterisk: http://the-asterisk-book.com - http://das-asterisk-buch.de
Videos of the AMOOCON VoIP conference 2009 ->  http://www.amoocon.de
-- 



More information about the asterisk-users mailing list