anya
April 26, 2012, 7:18pm
1
Hello everyone,
I’m newbie with asterisk and if you have time, please advice me. I want to run php script, for example I want to analyse some conditions and every time for every condition I set variable, for examle $call. Then I want to send variable $call into dialplan, and for every value of $call to do something, if $call is 1, Dial,…or if is not, hangup…
Cheers
Anya
dcabot
April 26, 2012, 8:49pm
2
First I’d install this:
phpagi.sourceforge.net/
Look for the demos for examples.
anya
April 26, 2012, 9:16pm
3
Yes, I know how to install everything, and I have it. My problem is syntax and logic how to past variable to Asterisk and to work something with it…
asteriskdocs.org/
There are example scripts in the contrib/scripts directory, in the source distribution.
Use: Set_Variable(“yourvariable”,“yourvalue”), then in your dialplan use it calling the name “yourvariable”, and thats all.
$mcount=3;
$agi->Set_Variable("count","${mcount}");
then in the dialplan:
....
same => n, NoOP( "the result of my count is ${count}")
.....
anya
April 27, 2012, 5:36am
6
Thank you all ! I will test it today, I hope without problems:) Or I will contact you again…thx once more
anya
April 27, 2012, 7:03am
7
Unfortunately, I have problem.
In php script I set variable
$my = 1;
$agi -> set_variable(“myvar”,"${my}");
Then in dialplan I wrote :
exten => XXX,1,Wait(1)
exten => XXX,2,AGI(script.php)
exten => XXX,n,NoOp(“the result is ${myvar}”)
exten => XXX,n,GotoIf($["${myvar}" = “1”]?yes:no)
exten => XXX,n(yes),Dial(SIP/XXX)
exten => XXX,n(no),Dial(SIP/XXX)
exten => XXX,n,Hangup()
But I got nothing in variable
Executing […] NoOp(“SIP/XXX-…”, ""the result is “”) in new stack
What is the result of enabling AGI debugging in the Asterisk CLI?