VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
abidarbaha91 at gmail.com Guest
|
Posted: Tue Sep 23, 2014 12:26 pm Post subject: [asterisk-users] read digits from the user through php agi s |
|
|
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
|
|
Back to top |
|
|
EWieling at nyigc.com Guest
|
Posted: Tue Sep 23, 2014 12:31 pm Post subject: [asterisk-users] read digits from the user through php agi s |
|
|
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@lists.digium.com [mailto:asterisk-users-bounces@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
|
|
Back to top |
|
|
abidarbaha91 at gmail.com Guest
|
Posted: Tue Sep 23, 2014 1:30 pm Post subject: [asterisk-users] read digits from the user through php agi s |
|
|
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@nyigc.com (EWieling@nyigc.com)> wrote:
Quote: |
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@lists.digium.com (asterisk-users-bounces@lists.digium.com) [mailto:asterisk-users-bounces@lists.digium.com (asterisk-users-bounces@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
|
|
Back to top |
|
|
asterisk_list at earth... Guest
|
Posted: Wed Sep 24, 2014 3:03 am Post subject: [asterisk-users] read digits from the user through php agi s |
|
|
On Tuesday 23 Sep 2014, Brahim Abidar wrote:
Quote: | 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.
|
Why do you want to do this in an AGI? It's easy enough to do in the dialplan.
Here's how I did it; you'll need to substitute your own sound bytes,
obviously, but I've added comments showing what they say:
[get_pin]
exten => s,1,Set(pin=)
exten => s,n,Set(PINLENGTH=4)
; "Enter your PIN. If you make a mistake, press STAR."
exten => s,n(prompt),Background(ajs-enter_pin)
; Build up the PIN digit by digit. The WaitExten() will be cut short by any
; keystroke, so we can use a quite longish timeout.
exten => s,n(nextdigit),WaitExten(30)
; "Sorry, I didn't get that."
exten => s,n,Playback(ajs-sorry_didnt_get)
exten => s,n,GoToIf($[${LEN(${pin})}<1]?prompt:saysofar)
; "The digits entered so far are:"
exten => s,n(saysofar),Playback(ajs-digits_so_far)
exten => s,n,SayDigits(${pin})
exten => s,n,Goto(nextdigit)
; This context needs to have a "h" extension; because we may well be
; placing a call from here, if the PIN was correct.
exten => h,1,NoOp(Clearing up)
; ..... carry on tidying up after ourselves
; "PIN cleared. Start again from the beginning."
exten => *,1,Playback(ajs-start_again)
exten => *,2,GoTo(get_pin,s,1)
exten => #,1,Hangup()
exten => _X,1,Set(pin=${pin}${EXTEN:0:1})
exten => _X,n,NoOp(PIN so far is ${pin})
exten => _X,n,GoToIf($[${LEN(${pin})}>=${PINLENGTH}]?got_all:need_more)
exten => _X,n(need_more),GoTo(get_pin,s,nextdigit)
; We have all 4 digits .....
exten => _X,n(got_all),NoOp(PIN is ${pin})
; ..... and we continue from here with the PIN in ${pin}
--
AJS
Note: Originating address only accepts e-mail from list! If replying off-
list, change address to asterisk1list at earthshod dot co dot uk .
--
_____________________________________________________________________
-- 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 |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|