[asterisk-users] Cisco 79xx XML services

Anciso, Roy roy at manistee.org
Mon Jan 7 15:16:41 CST 2008


Although it's not LDAP I used a script that I found on the voip wiki and
changed it so it looked at only sip configuration files. It also
alphabetizes the output so it can be displayed that way on the phone.
Below are my notes on the subject.  If someone is willing to post this
to the wiki and send me a link, that would be awesome.

 

Cisco Phone Extension Directory Using Services Button
I used a PHP script that I found on the Internet and rewrote it to fit
our needs.  Original code is found at:
http://users.marshall.edu/~twohig5/directory.php.txt
The new code only looks at the sip.conf file since we are only using sip
phones. My version also alphabetizes the directory.  Below is the source
code:



Directory.php.txt
<?
header("Content-type: text/xml");
header("Connection: close");
header("Expires: -1");
 
// location of asterisk config files
$location = "/etc/asterisk/";
$dirname = "MISD Directory";
 
// parse sip.conf
$sip_array = parse_ini_file($location."sip.conf", true);
while ($v = current($sip_array))
{ if (isset($v['name']))
{ $directory[] = "<Name>". $v['name']."</Name>\n".
    "<Telephone>".key($sip_array)."</Telephone>\n";
}
next($sip_array);
}
 
sort ($directory);
 
echo "<CiscoIPPhoneDirectory>\n";
echo "<Title>".$dirname."</Title>\n";
foreach ($directory as $v) {
  echo "\n<DirectoryEntry>\n";
  echo $v;
  echo "</DirectoryEntry>\n";
}
echo "\n<Prompt>Choose Name and Press Dial</Prompt>\n";
echo "</CiscoIPPhoneDirectory>\n";
?>

 


More information about the asterisk-users mailing list