Read function in PHPAgi

Hi

I am using Read function is PHPAGI. It is working fine , play IVR , time out , repeat IVR all are working but it does not store DTMF value in variable. Following is code. Please advise.

$agi->exec(‘Read’, “DTMF,$main_ivr,1,2,3”);
$agi->verbose(“DTMF number entered $DTMF”)

the value of main_ivr plays but dtmf value should store in DTMF which does not.

<SIP/1003-00000003>AGI Tx >> agi_callington: 0
<SIP/1003-00000003>AGI Tx >> agi_callingtns: 0
<SIP/1003-00000003>AGI Tx >> agi_dnid: 123
<SIP/1003-00000003>AGI Tx >> agi_rdnis: unknown
<SIP/1003-00000003>AGI Tx >> agi_context: agents
<SIP/1003-00000003>AGI Tx >> agi_extension: 123
<SIP/1003-00000003>AGI Tx >> agi_priority: 2
<SIP/1003-00000003>AGI Tx >> agi_enhanced: 0.0
<SIP/1003-00000003>AGI Tx >> agi_accountcode:
<SIP/1003-00000003>AGI Tx >> agi_threadid: 140292557551360
<SIP/1003-00000003>AGI Tx >> agi_arg_1: queue-periodic-announce
<SIP/1003-00000003>AGI Tx >>
<SIP/1003-00000003>AGI Rx <<
<SIP/1003-00000003>AGI Tx >> 510 Invalid or unknown command
<SIP/1003-00000003>AGI Rx << EXEC Read DTMF,queue-periodic-announce,1,2,3
– AGI Script Executing Application: (Read) Options: (DTMF,queue-periodic-announce,1,2,3)
– Accepting a maximum of 1 digits.
– <SIP/1003-00000003> Playing ‘queue-periodic-announce.gsm’ (language ‘en’)
– User entered ‘2’
<SIP/1003-00000003>AGI Tx >> 200 result=0
<SIP/1003-00000003>AGI Rx << VERBOSE "DTMF number entered " 1
action.php,queue-periodic-announce: DTMF number entered
<SIP/1003-00000003>AGI Tx >> 200 result=1
– <SIP/1003-00000003>AGI Script action.php completed, returning 0
– Executing [123@agents:3] Hangup(“SIP/1003-00000003”, “”) in new stack

Why dont use $agi->get_data() ?

Hi ambiorixg

Thanks for replying. One advantage of using Read is to easily control number of times IVR would be repeated. Moreover I was not able to play announcement through get_data. Following is code and Logs. I am using PHP 7 on cantos 7.

$result = $agi->get_data(${ivr},5000,1);
$keys = $result[‘result’];

$agi->verbose(“The DTMF entered by customer is $keys”);

Logs::::::

<SIP/1003-0000001c>AGI Tx >> agi_accountcode:
<SIP/1003-0000001c>AGI Tx >> agi_threadid: 140289183733504
<SIP/1003-0000001c>AGI Tx >> agi_arg_1: queue-periodic-announce
<SIP/1003-0000001c>AGI Tx >> agi_arg_2: 0
<SIP/1003-0000001c>AGI Tx >>
<SIP/1003-0000001c>AGI Rx <<
<SIP/1003-0000001c>AGI Tx >> 510 Invalid or unknown command
<SIP/1003-0000001c>AGI Rx << GET DATA queue-periodic-announce 5000 1
– <SIP/1003-0000001c> Playing ‘queue-periodic-announce.gsm’ (language ‘en’)
<SIP/1003-0000001c>AGI Rx << VERBOSE "The DTMF entered by customer is " 1

You can control how many times the sound will be played also from the PHP code, I havent use read directly on the AGI class, if you want to do it I suggest read the documentation or use read directly on the Asterisk dialplan and pass the value back to the AGI as an argument

Yes Now I am controlling through dial-plan and passing argument. One question it may be issue of read or get_data due to new version of php? as I have previously used it in agi.