[asterisk-users] read digits from the user through php agi script

Brahim Abidar abidarbaha91 at gmail.com
Tue Sep 23 13:29:25 CDT 2014


thank you Eric for your response
i will extract what i need in your function even i already test this :
exten=> 777,1,Answer()
exten=> 777,n,Read(digits,,1,,,3000)
exten=> 777,n,SayNumber(${digits})
exten=> 777,n,Hangup()

and it works for me but i don't know how to convert it to PHPAGI


On 23 September 2014 18:31, Eric Wieling <EWieling at nyigc.com> wrote:

> I’m not going to help you debug your code, but I wanted to post part of a
> function from one of our internal AGIs which reads auth codes using a
> simple IVR.  The code is ugly but it might be helpful to you.   This code
> is released to the public domain.
>
>
>
>     // no pin provided, get pin from caller
>
>     $agi->answer();
>
>     usleep(250000);
>
>
>
>     $try = 1;
>
>     $bad_pass = FALSE;
>
>     $auth_start_time = microtime(TRUE);
>
>     while ($try < 4) {
>
>         if ($try == 1) {
>
>             $agi->exec("Read", "pin,/igc/sounds/cc-bong,$pinset_len,,1,3");
>
>         } else {
>
>             if ($pinset_len == 0) {
>
>                 $agi->exec("Read",
> "pin,please-enter-your&access-code&/igc/sounds/cc-bong,,,1,5");
>
>             } else {
>
>                 $agi->exec("Read",
> "pin,please-enter-your&digits/$pinset_len&digit&access-code&/igc/sounds/cc-bong,$pinset_len,,1,5");
>
>             }
>
>         }
>
>         $temp = $agi->get_variable("pin");
>
>         $pin = trim($temp["data"]);
>
>
>
>         if ($pinset_verify == "1" && $pin != "") {
>
>             $temp = array_search($pin, $pins);
>
>             if ($temp !== FALSE) {
>
>                 $agi->set_variable("SM_START", $sm_start +
> (microtime(TRUE) - $auth_start_time));
>
>                 $agi->exec("CELGenUserEvent", "\"SM,status => OK, cause
> =>000, detail => Verified PIN, pin => $pin\"");
>
>                 return array("status" => "OK", "cause" =>"000", "detail"
> => "Verified PIN", "pin" => $pin);
>
>             }
>
>         } else if ($pinset_verify != "1" && $pin != "") {
>
>             $agi->set_variable("SM_START", $sm_start + (microtime(TRUE) -
> $auth_start_time));
>
>             $agi->exec("CELGenUserEvent", "\"SM,status => OK, cause =>000,
> detail => Unverified PIN, pin => $pin\"");
>
>             return array("status" => "OK", "cause" =>"000", "detail" =>
> "Unverified PIN", "pin" => $pin);
>
>         }
>
>
>
>         if ($try != "1") {
>
>             $agi->exec("Playback", "bad&access-code");
>
>         }
>
>         $try++;
>
>     }
>
>
>
>     $agi->set_variable("SM_START", $sm_start + (microtime(TRUE) -
> $auth_start_time));
>
>     $agi->exec("CELGenUserEvent", "\"SM,status => ERROR, cause =>851,
> detail => Verified PIN, pin => $pin\"");
>
>     return array("status" => "ERROR", "cause" =>"851", "detail" =>
> "Verified PIN", "pin" => $pin);
>
>
>
> }
>
>
>
>
>
> *From:* asterisk-users-bounces at lists.digium.com [mailto:
> asterisk-users-bounces at lists.digium.com] *On Behalf Of *Brahim Abidar
> *Sent:* Tuesday, September 23, 2014 1:26 PM
> *To:* Asterisk Users Mailing List - Non-Commercial Discussion
> *Subject:* [asterisk-users] read digits from the user through php agi
> script
>
>
>
> hi everyone,
> actually i want to release an IVR system using PHPAGI API , in this IVR i
> want to get value from the user.
>
> I already used get_data defined in phpagi but they are not able to get the
> value given by the user and store it in a php variable.
>
> i tested this :
>
> $result = $agi->get_data('beep', 3000, 20);
>
> $keys = $result['result'];
>
>
>
> but every time i found in $keys variable 0.
>
>
> please any help or suggestions
> thank you for spending your valuable time for me.
>
>
>
> --
>
>
> *Élève Ingénieur INE3 à l'Institut National des Postes et
> Télécommunications * *INPT - Rabat - Maroc*
>
>
> *Responsable de la cellule Asterisk au Club Electronique et Systemes
> Embarqués de l'INPT*
>
> *Membre du projet " ilearn", SIFE INPT*
>
>
> *     Tel : +212642398782*
>
>        *Skype  : abidarbrahim*
>
>
>
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>                http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-users
>



-- 

*Élève Ingénieur INE3 à l'Institut National des Postes et
Télécommunications * *INPT - Rabat - Maroc*


 *Responsable de la cellule Asterisk au **Club Electronique et Systemes
Embarqués de l'INPT*
*Membre du projet " ilearn", SIFE INPT*


*     Tel : +212642398782*

*       Skype  : abidarbrahim*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140923/618fefa9/attachment.html>


More information about the asterisk-users mailing list