Simon wrote:

Hello all

Has anyone had any success with the Manager API ?

I am trying to check an extension status without too much luck I have
the following

<?php
$fp = fsockopen("127.0.0.1", 5038, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "Action: Login\r\n";
$out .= "UserName: simon\r\n";
$out .= "Secret: xxxxxx\r\n\r\n";
fwrite($fp, $out);
$in = "Action: ExtensionState\r\n";
$in .= "Exten: 4367\r\n\r\n";
$in .= "Context: office\r\n\r\n"; $in .= "ActionID: \r\n\r\n";
$in .= "Action: Logoff\r\n\r\n";
fwrite($fp,$in);
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>


The first prob is it ignores the Context and just goes to default.
The second is anyone know what ActionID is ?

Best Regards
Simon



----------------------------------------------- This message has been scanned for viruses and
dangerous content by OrbitalNet, and is
believed to be clean. If you have any concerns
with this message please email us,
[EMAIL PROTECTED] / http://www.orbital.net
-----------------------------------------------


_______________________________________________
Asterisk-Users mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users


Here is the php code that works for me:
I use this to get a list of extensions that are in use.

$socket = fsockopen("127.0.0.1","5038", $errno, $errstr, $timeout);
fputs($socket, "Action: Login\r\n");
fputs($socket, "UserName: xxxxxxx\r\n");
fputs($socket, "Secret: xxxxxxx\r\n\r\n");
fputs($socket, "Action: command\r\n");
fputs($socket, "Command: show channels\r\n\r\n");
fputs($socket, "Action: Logoff\r\n\r\n");

while (!feof($socket)) {
$wrets = fgets($socket, 4096);
$wrets = trim($wrets);
if(substr($wrets,0,3)=="SIP"){
$m_start = strpos($wrets,'/');
$m_end = strpos($wrets,'-');
$m_ext = substr($wrets,$m_start+1,($m_end-$m_start)-1);

//do something here with the extension number

}
if(substr($wrets,0,4)=="IAX2"){
$m_start = strpos($wrets,'/');
$m_end = strpos($wrets,'@');
$m_ext = substr($wrets,$m_start+1,($m_end-$m_start)-1);

//do something here with the extension number

}
}

fclose($socket);


I think ActionID is just an ID number for your own use.

Malcolm
_______________________________________________
Asterisk-Users mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to