[asterisk-users] AGI PHP
Danny Nicholas
danny at debsinc.com
Mon May 4 15:30:19 CDT 2009
Just my .02. In my asterisk (1.4.21.2 using Polycom phones), The read in
AGI doesn't work as expected. This is a simple thing to do in a dialplan
and pass to php for the "lifting".
Here's what I would do:
exten => s,1(readq1),Read(digitq1,record/q1,16,skip,1,10])
exten => s,n,Gotoif($["${LEN(${digitacc})}" < "1"]?readq1)
exten => s,n,AGI(checkdigit.php|${digitq1})
Not the answer you want and I'm sure someone will give you the correct
answer if I'm wrong.
_____
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of James A.
Shigley
Sent: Monday, May 04, 2009 3:17 PM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: [asterisk-users] AGI PHP
I'm just trying to make a real simple Survey via php. Just want it to play
the Question Files, wait for a response, save the response into the correct
variable and then email it all.
I have no issue playing the audio or emailing. But I can't get it to wait
for digits or to properly capture those digits into the variables. I know
the code is technically right since the emails have this in place of what Q1
should be "200 result=35 endpos=2400" instead of whatever digit I pressed
during testing.
Anyway my questions are
A. How to have it play the whole audio file before it goes to the next
command, without having to use the sleep function preferably.
B. How to make it actually wait for digits
C. How to get it to actually capture the digits (I think it would if it
wasn't streaming thru the whole file without waiting for a response.)
I'm just trying to capture digits 1-9 nothing fancy.
#!/usr/bin/php -q
<?php
// Get AGI vars from *
$agivars = array();
while (!feof(STDIN)) {
$agivar = trim(fgets(STDIN));
if ($agivar === '') {
break;
}
$agivar = explode(':', $agivar);
$agivars[$agivar[0]] = trim($agivar[1]);
}
extract($agivars);
// Variable Declarations
$agi_uniqueid;
$agi_callerid;
$agi_calleridname;
$agi_extension;
$agi_uniqueid;
$UNIQUEID = $agi_uniqueid;
$CALLERID = $agi_callerid;
$CallerName = $agi_calleridname;
$EXTEN = $agi_extension;
$Q1 = "Did Not Answer";
$Q2 = "Did Not Answer";
$Q3 = "Did Not Answer";
$Q4 = "Did Not Answer";
$Q5 = "Did Not Answer";
// Q1
fwrite(STDOUT, "STREAM FILE /var/lib/asterisk/sounds/1 ###\n");
fwrite(STDOUT, "wait for digit 10\n");
$Q1 = fgets(STDIN);
// This section is where the email would be generated, but since that
section works. No point making this any longer than need be.
?>
James Shigley
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090504/ee4131ae/attachment-0001.htm
More information about the asterisk-users
mailing list