[Asterisk-Dev] AGI-PHP, variable values are not showing
Moises Silva
moises.silva at gmail.com
Tue Aug 9 07:39:46 MST 2005
try sending this string to STDOUT so asterisk can read it:
EXEC SetVar somevariablename=somevariablevalue
best regards
On 8/9/05, Lambert <lambert at mindragon.com> wrote:
> im having some trouble with AGI-PHP, the script runs with no errors shown
> on CLI, i tried to save logs to see if the script is actually running and
> it is, but i cant seem to set any value to any variable, i tried using
> those variables in NoOp but none of those values are showing, anyone?
>
> heres the PHP script i used
>
> #!/usr/bin/php -q
> <?
> ob_implicit_flush(false);
> set_time_limit(5);
> error_reporting(0);
>
> $stdin = fopen("php://stdin", "r");
> $stdout = fopen("php://stdout", "w");
> $stdlog = fopen("/var/log/asterisk/mdi_agi.log", "a");
> $debug = true;
>
> // get AGI response
> ///////////////////
> function read()
> {
> global $stdin, $debug, $stdlog;
>
> $input = str_replace("\n", "", fgets($stdin, 4096));
> if ($debug)
> fputs($stdlog, "read: $input\n");
>
> return $input;
> }
>
> // send command to AGI
> //////////////////////
> function write($AGI)
> {
> global $stdout, $debug, $stdlog;
>
> fputs($stdout, "$AGI \n");
> fflush($stdout);
>
> if ($debug)
> fputs($stdlog, "write: $line\n");
> }
>
> // error/debug logs
> ///////////////////
> function errlog($log)
> {
> $global $debug, $stdlog;
> if ($debug)
> fputs($stdlog, "debug: $log\n");
> }
>
> // get AGI headers
> //////////////////
> while (!feof($stdin))
> {
> $temp = fgets($stdin);
> $temp = str_replace("\n","",$temp);
> $s = explode(":",$temp);
> $agivar[$s[0]] = trim($s[1]);
>
> if (($temp == "") || ($temp == "\n"))
> break;
> }
>
> errlog("Connect [ " . $agivar["agi_callerid"] . "]");
>
> write("SET VARIABLE ACCOUNTCODE \"someaccountcode\"");
> write("SET VARIABLE CALLERID \"somecallerid\" <12345678>");
> write("SET VARIABLE TEST_VARIABLE1 \"testvariable1\"");
> write("SET VARIABLE TEST_VARIABLE2 100");
>
> mysql_free_result($result);
> mysql_close($dbcon);
>
> // clean up file handlers
> /////////////////////////
> fclose($stdin);
> fclose($stdout);
> fclose($stdlog);
>
> errlog("Close [ " . $agivar["agi_callerid"] . "]");
>
> exit;
> ?>
>
>
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-dev
>
--
"Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"
More information about the asterisk-dev
mailing list