How to get Contacts Information to display on A30 phone?

I have been doing more research on this and now have solutions for the Asterisk Phonebook and the Contacts database. I thought I would report it here in case others find it useful.

Firstly you have to write PHP scripts to extract the data from the databases and convert it to XML to send to the phones. Here’s the one for the Asterisk Phonebook:

<?php
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<AsteriskIPPhoneDirectory>';

$db = new SQLite3('/var/lib/asterisk/astdb.sqlite3');

$results = $db->query('SELECT * FROM astdb;');

while ($row = $results->fetchArray()) {
    //find
    $find='/cidname/';
   
    if(strpos($row['key'], $find)!==false) {
        echo '<DirectoryEntry>';
            echo '<Name>'.htmlspecialchars($row['value']).'</Name>';
            echo '<Telephone>'.str_replace($find, '', $row['key']).'</Telephone>';
        echo '</DirectoryEntry>';
    }
}

echo '</AsteriskIPPhoneDirectory>';
?>

That was based on a script from vespino (Wesley van Kuijen) which was published in this thread:
https://community.freepbx.org/t/phonebook-store-location/36062/4

The script for accessing the Contacts database is written by sorvani (Jared Busch ). It did not require any changes. It can be found here:

https://github.com/sorvani/freepbx-helper-scripts/blob/master/ContactManager_to_Digium_AddressBook/cm_to_digum_aseries.php

Once you have those two PHP files, copy them into /var/www/html on your FreePBX system. There are many ways of doing this; I used WinSCP. I called one file phonebook.php and the other one contacts.php.

You can test the XML generation by pointing your browser at the files. Modern browsers seem to be able to check and display XML. You then have to tell the phones where to get the data. There are several ways of doing that; I chose to use the web GUI for the phones. Once logged in, go to Phonebook | Cloud Phonebook and enter the Name and URL (e.g. http://192.168.0.100/phonebook.php).

One the A20 phone, the phonebooks will appear on the Dir menu under Cloud Phonebook. The A30 phone is quite different and the data is found via Menu | Phonebook | Cloud Contacts. That’s a bit tedious so I reprogrammed the tick button to go straight there.

I hope this is useful to someone.

Thanks to vespino and sorvani for their work in the past which made it easy once I’d figured out how to use the information.

Bill.

1 Like