Access Channel Variable in PHP Script

I want to know the way to access the channel variable in PHP Script. Someone who knows this plz tell me. Very thanks in advance

did you forget already that you requested almost exactly the same in the thread below this one ??

if you bothered to read the wiki (searching for AGI and take the very first result !!) you’d see this :

voip-info.org/wiki-Asterisk+AGI

“get variable” and “set variable”. it doesn’t get much easier.

[quote=“baconbuttie”]

voip-info.org/wiki-Asterisk+AGI

“get variable” and “set variable”.[/quote]

My conf files are

;extensions.conf
[global]
clearglobalvars=yes
;CallLimit=10

[internal]
exten => 100,1,Macro(DialFunction,${EXTEN})
exten => 101,1,Macro(DialFunction,${EXTEN})
exten => 500,1,VoiceMailMain(@internal)
exten => 600,1,Playback(conf-thereare)
exten => 600,2,MeetMeCount(600)
exten => 600,3,Playback(conf-peopleinconf)
exten => t,1,Hangup()

[macro-DialFunction]
SetVar(CallLimit=0)
exten => s,1,Answer()
exten => s,n,AGI(test.agi)
exten => s,n,Dial(SIP/${ARG1},5,rL(${CallLimit}))
exten => s,n,VoiceMail(u${ARG1}@internal)
exten => s,n,Hangup()
exten => s,102,Playback(tt-allbusy)
exten => s,n,VoiceMail(b${ARG1}@internal)
exten => s,n,Hangup()

test.agi
<?php
?>

Now i want to increment the value of CallLimit by 1 in the script so that i could access the incremented value after the command where agi script was called. Waiting for your precious reply.

is that the limit of your PHP script ? the opening and closing tags ? show us what you have tried already.

you need to learn to use the wiki and google and not expect to be spoonfed all the answers.

a search on this forum, or a google for AGI docs would have given you (old, but still applicable) stuff like this : bitflipper.ca/Documentation/agi.html

This is my limit. I’m giving you the script

[b]#!/usr/bin/php4 -q

<?php GLOBAL stdin,stdout,stdlog,stderr; ob_implicit_flush(false); set_time_limit(5); error_reporting(0); if (!defined('stdin')) { define('stdin', fopen('php://stdin', 'r')); } if (!defined('stdout')) { define('stdout', fopen('php://stdout', 'w')); } if (!defined('stderr')) { define('stderr', fopen('php://stderr', 'w')); } if (!defined('stdlog')) { define('stdlog', fopen('php://var/lib/asterisk/agi-bin/my_agi.log', 'w')); } function execute($command) { fputs($stdout, $command . " \n"); fflush($stdout); $data = fgets($stdin, 4096); if (preg_match("�^([0-9]{1,3}) (.*)�", $data, $matches)) { if (preg_match('�^result=([0-9a-zA-Z]*)( ?\((.*)\))?$�', $matches[2],tch)) { $arr['code'] = $matches[1]; $arr['result'] = $match[1]; if (isset($match[3]) && $match[3]) $arr['data'] = $match[3]; return $arr; } else return 0; } else return -1; } $result = execute("GET VARIABLE CallLimit"); $result['data']=$result['data'] + 15000; fputs($stdlog, $result['data'] . " \n"); fflush($stdlog); fputs($stderr, $result['data']); $result = execute("SET VARIABLE CallLimit 30000"); // clean up file handlers etc. fclose($stdin); fclose($stdout); fclose($stdlog); fclose($stderr);[/b] and the extensions.conf is ;extensions.conf [internal] exten => 100,1,Macro(DialFunction,${EXTEN}) exten => 101,1,Macro(DialFunction,${EXTEN}) exten => 500,1,VoiceMailMain(@internal) exten => 600,1,MeetMe(600,1,54321) exten => t,1,Hangup() [macro-DialFunction] exten => s,1,Answer() [b]exten => s,n,SetVar(CallLimit=15000) exten => s,n,agi(test) exten => s,n,Dial(SIP/${ARG1},5,rL(${CallLimit}))[/b]exten => s,n,VoiceMail(u${ARG1}@internal) exten => s,n,Hangup() exten => s,102,Playback(tt-allbusy) exten => s,n,VoiceMail(b${ARG1}@internal) exten => s,n,Hangup() As my script shows, CallLimit should have 30000 value inside it but its showing me 15000 which was set b4 the script was called. Kindly tell me where i'm wrong. :unamused: