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

 

_______________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to