Hi i am new to programming.
After I send a curl from asterisk dial plan
I get back from a api something like this :
0:1027301|pe_id:1027301|1:ko ben|NAME:ko
ben|2:0555532963|PHONE2:0555532963|3:07711111|PHONE1:07711111|
i would like to set the variable just the number of phone 2
dont want use php or scripting
it is obvious you cant use the cut function !
For me one of the greatness of Asterisk is that you can use it in combination with other programming language like php
Asterisk provide some basic tools for string manipulation but I prefer use PHP or Python in some cases, in this case you could do it all using php curl function
<?php
$string="0:1027301|pe_id:1027301|1:ko ben|NAME:ko
ben|2:0555532963|PHONE2:0555532963|3:07711111|PHONE1:07711111|";
echo $value=preg_replace('/[^0-9]+/', '', stristr(stristr($string, 'PHONE2'),'|',true));
//print 20555532963
?>
Then you can save it on a channel variable using Shell() function
It is just one of the many ways how to do it
ambiorixg12:
is that you can use it in combination with other programming language like php
Asterisk provide some basic tools for string manipulation but I prefer use PHP or Python in some cases, in this case you could do it all using php curl function
yeah but it has it cost I don’t want to use it if I could get AROUND IT with the regular ael
Hi
Set(myvar1=${CUT(crlrslt,|,6)}); // set myvar to PHONE2:0555532963
Set(myvar=${CUT(myvar1,:,2)}); // set myvar to 0555532963
Be sure that func_cut.so module is loaded.
1 Like
system
Closed
September 18, 2019, 11:51am
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.