Page Contents
Known XML Phonebook Issues
BETA 1.1.1.14
- Fixed? (Oct03/06) – Setting the Remove Manually-edited entries on Download option to yes still causes phone to crash during the “Sync Phonebook XML…This may take a minute” screen. – acabtp
- I believe this has been fixed; I do not see this happening with this update (I haven’t checked the previous ones, just got around to it now). -Mike
- Phonebook XML download (Oct18/06) – Seems like it’s not possible download and sync more than 6! phonebook items. Tested with identical record adding one by one. I’m confident I could sync more real items early today with beta 1.1.0.13 firmware -MIlan
- Solved, not a bug thought- the XML page has been generated dynamically and was probably not too fast. The final XML document has not been valid and thus not parsed by GXP-2000.-MIlan
Beta 1.1.1.9
- MAJOR (Aug18/06) – Setting the Remove Manually-edited entries on Download option to yes still causes phone to crash during the “Sync Phonebook XML…This may take a minute” screen. – acabtp
- TWEAK (Aug18/06) – The interface for using the phonebook needs some rethinking. With a list of more than 20 entries, it quickly becomes cumbersome to navigate. Suggested changes:
- Pressing and holding the up or down arrows should scroll the list
- Pressing up when at the top of the list should take you to the bottom, and vice versa
- Typing numbers on the keypad should take you through the entries in the list that match that letter… ie, press 3 once for entries starting with D, twice for E, thrice for F… Similar to navigation of phone books on most cell phones.
- Pressing the Speaker button or lifting the handset with an entry selected in the list should dial it, without having to press the action key to get into the contact and then pressing the action key again to choose Dial. – acabtp
- FUNCTIONS (Sep10/06) – Suggested adds:
- An important one nowadays: allow the association of multiple phone numbers to the same contact name (It looks to me as if the XML syntax already caters for that, while the software not yet)
- Access the download function without having to scroll through all the phonebook entries
- A DELETE ALL ENTRIES function especially useful when performing complete rehauls of the phonebook. – xavtoit
Beta 1.1.1.7
- MAJOR (Jul17/06) – There seems to be a memory limit on the number of entries your phonebook can have. With more than approximately 15 entries, the phone will get stuck on Sync Phonebook XML…This may take a minute
- MAJOR (Jul18/06) – Setting the Remove Manually-edited entries on Download: option to yes causes Sync Phonebook XML…This may take a minute. Only way to fix it is to disconnect the network so it doesn’t find the file and disable the option. Is this happening for everybody? – Shane Steinbeck
- TWEAK (JUL17/06) If download fails for some reason, i.e. database is busy, the phone will act like it never got the command to download the phonebook. In one way this is good, so it doesn’t hang up the phone, but on the other hand an error message would be nice after a 30 sec timeout or so.– MikeB
- TWEAK (JUL18/06) Well the phone doesn’t give feedback if it doesn’t find a valid file, so if the problem lies between the phone and the script, there is nothing we can do. The one tweak that would be possible would be to write a descriptive “entry” into the XML if the database connection failed. Then the phonebook would contain an entry for Call, Support with a phone number. – Shane Steinbeck
XML Phonebook Manual
GXP XML phonebook guide
The feature will be activated when “Enable Downloadable Phonebookࢀ? Phonebook is set to YES (HTTP or TFTP) AND a valid “Phonebook XML Pathࢀ? XML Download is set.
When the device boot up and completed the provisioning routine, it will attempt to download the gs_phonebook.xml file specified in “Phonebook XML Pathࢀ?. During this process the LCD should display some messages to indicate that XML Phonebook download is in progress.
If the “Phonebook Download Intervalࢀ? is set to a non-zero value, GXP2000 will periodically check and download the updated phonebook available.
If the “Remove manually edited entries on downloadࢀ? option is set to NO (by default), GXP2000 will keep ALL entries edited manually, and insert the downloaded entries, and then save the phonebook. Otherwise ALL the existing phonebook entries on the phone will be erased and filled with the downloaded entries.
At any time, you can trigger an immediate download from by choosing the “Download Phonebookࢀ? in the GUI Phone Book Menu (you can use the down arrow key when the phone is on-hook).
Example XML file of gs_phonebook.xml:
<?xml version="1.0"?> <AddressBook> <Contact> <LastName>Craig</LastName> <FirstName>Richard</FirstName> <Phone> <phonenumber>6910</phonenumber> <accountindex>0</accountindex> </Phone> </Contact> <Contact> <LastName>Peterson</LastName> <FirstName>Susan</FirstName> <Phone> <phonenumber>6911</phonenumber> <accountindex>0</accountindex> </Phone> </Contact> <Contact> <LastName>Mayer</LastName> <FirstName>Cindy</FirstName> <Phone> <phonenumber>6915</phonenumber> <accountindex>0</accountindex> </Phone> </Contact> </AddressBook>
Note: This feature is designed for enterprise user only. Please contact Grandstream for more details.
Generate phonebook from Outlook
The code below shows vbscript that will generate an xml phone book for a given Outlook mail profile. If you use Exchange, this will probably be your name.
Const OUTLOOK_PROFILE = "Tim Smith" '(Change to your mail profile name) Set oOutlook = CreateObject("Outlook.Application") Set ns = oOutlook.GetNamespace("MAPI")crlf = chr(13) & chr(10) sHtml = "<?xml version=""1.0""?>" & crlf sHtml = sHtml & "<AddressBook>" & crlfSet oSession = CreateObject("MAPI.Session") oSession.Logon OUTLOOK_PROFILE olFolderContacts = 10 olContactClassID = 40 Set fld = ns.GetDefaultFolder(olFolderContacts) For Each oContact In fld.Items If cint(oContact.Class) = olContactClassID Then sHtml = sHtml & ContactToXML(oContact, PhoneType_HOME, oContact.HomeTelephoneNumber) ContactToXML = "<Contact>" & crlf sHtml = sHtml & "<LastName>" & oContact.LastName & "</LastName>" & crlf sHtml = sHtml & "<FirstName>" & oContact.FirstName & "</FirstName>" & crlf sHtml = sHtml & "<Phone>" & crlf sHtml = sHtml & "<phonenumber>" & oContact.BusinessTelephoneNumber & "</phonenumber>" & crlf sHtml = sHtml & "<accountindex>0</accountindex>" & crlf sHtml = sHtml & "</Phone>" & crlf sHtml = sHtml & "</Contact>" & crlf End If Next sHtml = sHtml & "</AddressBook>"
Dynamic XML Phonebook from MySQL table
MySQL table create script
Run the SQL script below in phpmyadmin or the mysql command line. Insert your phonebook entries while you’re there. This accepts integer phone numbers only for now.
CREATE TABLE `bit_phonebook` ( `id` int(11) NOT NULL auto_increment, `LastName` varchar(30) NOT NULL, `FirstName` varchar(30) NOT NULL, `phonenumber` varchar(10) NOT NULL, `accountindex` smallint(6) NOT NULL default '0', PRIMARY KEY (`id`), KEY `fname` (`LastName`,`FirstName`,`phonenumber`) ) COMMENT='GXP-2000 Phonebook';
I’ve changed definition of filed “phonenumber” becouse when you used the orginal structure, MySQL cutted-off leading 0 from number. (Marcin Kowalczyk)
PHP script
This script accesses the MySQL table created in the prior section. It generates the xml phonebook dynamically from the populated mysql phonebook table. Save this php script on your web server as gs_phonebook.php in a directory that the GXP-2000 can access via http port 80.
<?php // File: gs_phonebook.php // version: 1.0 // Date: 07-17-2006 // Author: Shane Steinbeck http://www.steinbeckconsulting.com // Description: Realtime XML phonebook from MySQL database for Grandstream GXP-2000 firmware 1.1.1.17 header("Content-type: text/xml"); $host = "localhost"; $user = "dbuser"; $pass = "dbpassword"; $database = "dbname"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT LastName, FirstName, phonenumber, accountindex FROM phonebook ORDER BY LastName ASC, FirstName ASC"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<AddressBook>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<Contact>\n"; $xml_output .= "\t\t<LastName>" . $row['LastName'] . "</LastName>\n"; $xml_output .= "\t\t<FirstName>" . $row['FirstName'] . "</FirstName>\n"; $xml_output .= "\t\t\t<Phone>\n\t\t\t\t<phonenumber>" . $row['phonenumber'] . "</phonenumber>\n"; $xml_output .= "\t\t\t\t<accountindex>" . $row['accountindex'] . "</accountindex>\n"; $xml_output .= "\t\t\t</Phone>\n"; $xml_output .= "\t</Contact>\n"; } $xml_output .= "</AddressBook>";
/***************************************************************************************
- Author: Mike
- Date: 10/03/2006
- This snipplet will save your xml file to the server for easier updating of your phone.
- To facilitate automatic updates, add a cron job to run this file at your desired interval (i.e. hourly).
$fp = fopen('gs_phonebook.xml', 'wb'); fwrite($fp, $xml_output); fclose($fp); /**************************************************************************************/ print($xml_output); echo $xml_output; ?>
Alternate PHP Script that has additional field ‘TYPE’
I created an additional field in my phonebook script called ‘type’ that will help identify the type of number as follows:
- H = Home
- W = Work
- C = Cell
- F = Fax
- P = Pager
- M = Mobile
This change will require that an additional field be added to your phonebook table: CREATE TABLE `bit_gxp_phonebook` ( `id` int(10) unsigned NOT NULL auto_increment, `first_name` tinytext NOT NULL, `last_name` tinytext NOT NULL, `phone_number` tinytext NOT NULL, `account_index` tinyint(3) unsigned NOT NULL default '0', `type` char(1) default NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1; The following is my script: <?php // File: gs_phonebook.php // version: 1.0 // Date: 07-17-2006 // Author: Shane Steinbeck http://www.steinbeckconsulting.com // Description: Realtime XML phonebook from MySQL database for Grandstream GXP-2000 firmware 1.1.1.17 header("Content-type: text/xml"); $host = "[server]"; $user = "[uid]"; $pass = "[pwd]"; $database = "[db]"; $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); mysql_select_db($database, $linkID) or die("Could not find database."); $query = "SELECT first_name ,last_name ,account_index ,phone_number ,type FROM gxp_phonebook ORDER BY last_name ASC ,first_name"; $resultID = mysql_query($query, $linkID) or die("Data not found."); $xml_output = "<?xml version=\"1.0\"?>\n"; $xml_output .= "<AddressBook>\n"; for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++) { $row = mysql_fetch_assoc($resultID); $xml_output .= "\t<Contact>\n"; $xml_output .= "\t\t<LastName>" . $row['last_name'] . "</LastName>\n"; $xml_output .= "\t\t<FirstName>" . $row['first_name'] . " [" . $row['type'] . "]</FirstName>\n"; $xml_output .= "\t\t\t<Phone>\n\t\t\t\t<phonenumber>" . $row['phone_number'] . "</phonenumber>\n"; $xml_output .= "\t\t\t\t<accountindex>" . $row['account_index'] . "</accountindex>\n"; $xml_output .= "\t\t\t</Phone>\n"; $xml_output .= "\t</Contact>\n"; } $xml_output .= "</AddressBook>"; $fp = fopen('gs_phonebook.xml', 'wb'); fwrite($fp, $xml_output); fclose($fp); print($xml_output); ?>
GXP-2000 Configuration
To get GXP-2000 to use the script
- Log into the GXP-2000 web interface and change:
- Enable Phonebook XML Download: YES, HTTP.
- Phonebook XML Server Path to point to the .php on your webserver (i.e. 192.168.1.1/gs_phonebook.php).
- Remove Manually-edited entries on Download: NO
- Reboot and it should pull info out of the phonebook table
Dynamic XML Phonebook from Asterisk CallerID database
By Kurgan, 12 Oct 2006
It is possible to load the phonebook from the Asterisk CallerID database, thus using a single database (that is stored in Berkeley DB format inside Asterisk) to show caller names when receiving calls and to call people from the GXP-2000 phonebook.
This setup was tested using Asterisk 1.0.7 from Debian Sarge, and is far from being really “user friendly”. It surely needs a better interface to manage the database, but it works and it is user friendly, as log as the users don’t mess with the DB.
You need Apache and PHP on the same box that runs asterisk to create the XML phonebook file and to serve it to the phones via HTTP. You also need “sudo” because the user that apache runs as needs to be able to extract the database data from Asterisk. I know it’s not really secure, but I have no users other than me on my PBX box, and the web interface is not accessible from the internet, so I suppose it should be acceptable.
First of all, you have to allow Apache to run asterisk to read out the database data, this is done by adding the following rule to /etc/sudoers:
Then, add some test entries in Asterisk CID database. Run “asterisk -r” and enter:
Then, edit your dialplan (extensions.conf) to add the command to lookup cid name when a call comes in.
Then, put this script (named cid-xml.php) where it can be executed by your web server:
<?php print("<?xml version=\"1.0\"?>\n<AddressBook>\n"); set_time_limit(5); system("sudo /usr/sbin/asterisk -rx \"database show cidname\" > /tmp/asterisk_cid-list.txt"); $fd=fopen("/tmp/asterisk_cid-list.txt","r"); while ($line=fgets($fd,1000)) { if (strpos ($line,"cidname") == true) { $nome=trim(substr($line,strpos($line,":")+1)); $startpos=strpos($line,"cidname")+8; $numero=trim(substr($line,$startpos,strpos($line,":")-$startpos)); print("<Contact>\n<LastName>"); print($nome); print("</LastName>\n<Phone>\n<phonenumber>"); print($numero); print("</phonenumber>\n<accountindex>0</accountindex>\n</Phone>\n</Contact>\n"); } } fclose ($fd); print("</AddressBook>"); ?>
Finally, configure the phones to load XML phonebook using HTTP, setting the URL to your script.
This setup is based on ideas taken from Asterisk cmd LookupCIDName and Asterisk tips managing CID names. You should check these pages too.