Hi folks, I need some help from php/agi experts out there; I am having difficulties in extracting the callerid number from php. My script is given below; #!/usr/local/bin/php -q <?php //environment dump ob_implicit_flush(true); set_time_limit(0); $err=fopen("php://stderr","w"); $in = fopen("php://stdin","r"); while (!feof($in)) { $temp = str_replace("\n","",fgets($in,4096)); echo "VERBOSE \"$temp\"\n"; if (($temp == "") || ($temp == "\n")) { break; } } ?> And the Response is: getenv.agi: agi_request: getenv.agi getenv.agi: agi_channel: SIP/-081524c0 getenv.agi: agi_language: en getenv.agi: agi_type: SIP getenv.agi: agi_uniqueid: 1079819757.97 getenv.agi: agi_callerid: Sathya <====================getenv.agi: agi_dnid: unknown getenv.agi: agi_rdnis: unknown getenv.agi: agi_context: default-in getenv.agi: agi_extension: 91234 getenv.agi: agi_priority: 1 getenv.agi: agi_enhanced: 0.0 getenv.agi: agi_accountcode: Actual caller ID is ; "Sathya Weerasooriya"<1001>, but what I get from this PHP is only first part. When I run the example test script in agi-bin directory, I get the correct callerid. I am using PHP 4.3.5CR xx. Any help is appreciated. Sathya -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20040320/e5533842/attachment.htm
Your script is receiving the data correctly, as you will see if you actually dump that data to a file rather than back to the asterisk console. The problem is actually in your VERBOSE statement. You are passing back this string: VERBOSE ""Sathya Weerasooriya" <1001>" Naturally asterisk is confused by this quote nesting. Try this line instead: echo "VERBOSE \"".str_replace("\"", "\\\"", $temp)."\"\n"; David Sathya wrote:> Hi folks, > > I need some help from php/agi experts out there; > > I am having difficulties in extracting the callerid number from php. My > script is given below; > > #!/usr/local/bin/php -q > <?php > //environment dump > > ob_implicit_flush(true); > set_time_limit(0); > > $err=fopen("php://stderr","w"); > $in = fopen("php://stdin","r"); > while (!feof($in)) { > $temp = str_replace("\n","",fgets($in,4096)); > echo "VERBOSE \"$temp\"\n"; > if (($temp == "") || ($temp == "\n")) { > break; > } > } > ?> > > And the Response is: > > getenv.agi: agi_request: getenv.agi > getenv.agi: agi_channel: SIP/-081524c0 > getenv.agi: agi_language: en > getenv.agi: agi_type: SIP > getenv.agi: agi_uniqueid: 1079819757.97 > getenv.agi: agi_callerid: Sathya <====================> getenv.agi: agi_dnid: unknown > getenv.agi: agi_rdnis: unknown > getenv.agi: agi_context: default-in > getenv.agi: agi_extension: 91234 > getenv.agi: agi_priority: 1 > getenv.agi: agi_enhanced: 0.0 > getenv.agi: agi_accountcode: > > Actual caller ID is ; "Sathya Weerasooriya"<1001>, but what I get from > this PHP is only first part. > > > When I run the example test script in agi-bin directory, I get the > correct callerid. > > I am using PHP 4.3.5CR xx. > > Any help is appreciated. > > Sathya
Hi David, Thanks, yes that was the problem. Really appreciate your tip. Cheers Sathya From: David Croft <davidc@sargasso.net> Organization: Sargasso Networks To: asterisk-users@lists.digium.com Subject: Re: [Asterisk-Users] can't get the full callerid php/agi Reply-To: asterisk-users@lists.digium.com Your script is receiving the data correctly, as you will see if you actually dump that data to a file rather than back to the asterisk console. The problem is actually in your VERBOSE statement. You are passing back this string: VERBOSE ""Sathya Weerasooriya" <1001>" Naturally asterisk is confused by this quote nesting. Try this line instead: echo "VERBOSE \"".str_replace("\"", "\\\"", $temp)."\"\n"; David