FreePBX | Register | Issues | Wiki | Portal | Support

Yealink XML Phonebook.xml auto-generation


(Greg) #1

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);

?>

#2

Great script! I have a similar one that generates phonebook simultaneously for yealink, grandstream and snom.


(Jared Busch) #3

Here is one I wrote.

This one is designed to be called live from the phone button.


Yealink phones and PBXact Contacts