@gbaughma wrote:
So, I wrote a script that generates the XML Phonebook for Yealink phones.
Enjoy!
Note: username and password need to have select access to the database
<?php $mysql_conn = mysql_connect('localhost','username','password'); mysql_select_db('asterisk', $mysql_conn); $query = 'SELECT description AS Name, user AS Telephone FROM devices WHERE tech="sip"'; $result = mysql_query($query, $mysql_conn); if (! $result){ echo mysql_error(); } $Output = "<YealinkIPPhoneDirectory>\n"; while($data = mysql_fetch_assoc($result)){ $results[] = $data; $Output .= " <DirectoryEntry>\n"; foreach($data as $key => $value){ $Output .= " <$key>$value</$key>\n"; } $Output .= " </DirectoryEntry>\n"; } $Output .= "</YealinkIPPhoneDirectory>\n"; // echo $Output; file_put_contents('Phone.xml',$Output); ?>
Posts: 1
Participants: 1