[Asterisk-Users] PHP-AGI help

Lewis Agosta voipstreet at gmail.com
Mon Jun 5 08:18:05 MST 2006


Yes.  Jon is correct.

$agi[str_replace("agi_","",$s[[0])] = trim($s[[1]);

This line needs some work...  Your brackets are mismatched.


On 6/2/06, Jon Farmer <viperdude_uk at yahoo.co.uk> wrote:
>
> Yes you have a parse error in your PHP when I saved it locally and run it
> from the command line I got
>
> syntax error, unexpected '[', expecting ']' in test.php on line 33
>
> Jon FarmerTelford, Shropshire, UK
>
> ----- Original Message ----
> From: Matthew Warren <mwarren at ru-intouch.com>
> To: asterisk-users at lists.digium.com
> Sent: Friday, 2 June, 2006 3:32:10 PM
> Subject: [Asterisk-Users] PHP-AGI help
>
> Can someone help me with this AGI script to send an email.  It just isn't
> working.  The file is being called in the dialplan and is saved as em.agi
> but it isn't sending the email.
> #!/usr/bin/php4 -q
> <?php
> ob_implicit_flush(true);
> set_time_limit(6);
> $in = fopen("php://stdin","r");
> $stdlog = fopen("/var/log/asterisk/my_agi.log", "w");
>
> // toggle debugging output (more verbose)
> $debug = false;
>
> // Do function definitions before we start the main loop
> function read() {
>   global $in, $debug, $stdlog;
>   $input = str_replace("\n", "", fgets($in, 4096));
>   if ($debug) fputs($stdlog, "read: $input\n");
>   return $input;
> }
>
> function errlog($line) {
>   global $err;
>   echo "VERBOSE \"$line\"\n";
> }
>
> function write($line) {
>   global $debug, $stdlog;
>   if ($debug) fputs($stdlog, "write: $line\n");
>   echo $line."\n";
> }
>
> // parse agi headers into array
> while ($env=read()) {
>   $s = split(": ",$env);
>   $agi[str_replace("agi_","",$s[[0])] = trim($s[[1]);
>   if (($env == "") || ($env == "\n")) {
>     break;
>   }
> }
>
>
>    $sender = "prospect at talktomehomes.com";
>    $recipient = "mwarren at cwgo.com";
>    $subject = "call from someone";
>
>
>
>    $header = "From: " . $sender . "\r\n";
>    $header.= "Reply-to: " . $sender . "\r\n";
>
>
>    mail($recipient, $subject, $message, $header);
>
>
> fclose($in);
> fclose($stdlog);
>
> exit;
> ?>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>
>
>
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
>   http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 
Origination that includes real support!
http://www.VoIPStreet.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20060605/0e1db0a7/attachment.htm


More information about the asterisk-users mailing list