Use a php file to create a dynamic Yealink Remote Address book of FreePBX extensions
-
As noted in another post, I had a crappy but serviceable python script to create a Yealink formatted Remote Address Book. Then a random upvote on a post from a few months ago on SW reminded me that George1421 had mentioned that he had a
php
script to do the same thing.
So I contacted him and asked if I could have it, and then if I could publish it. Being the awesome guy he is, he said sure.His original script is now on github.
After reading it, I tweaked it to suit my own needs and added some comments and examples for the rest of the word and published it as
ylab.php
, short for Yealink Address Book.How to use it:
First, get the script onto your FreePBX install. Simplest is to copy paste it into
vi
ornano
. The file needs to be in the web directory. You can put it in a subfolder if you want. I just leaving it in the root.nano /var/www/html/ylab.php
Paste in the text from https://raw.githubusercontent.com/sorvani/freepbx-helper-scripts/master/ylab.php
Save the file and then give ownership to asterisk.
chown asterisk:asterisk /var/www/html/ylab.php
Now navigate to the URL of your PBX /ylab.php and make sure you can see the extensions.
https://pbx.domain.com/ylab.php
Now that you know it works, setup your phone.
Here is the config file method
Programmable key 2 is the second button from the left on the bottom of the screen of most Yealink Phones, and just where I like to put this. I also set the refresh to 3 hours (10800 seconds).features.remote_phonebook.data.1.name = ylab features.remote_phonebook.data.1.url = https://pbx.domain.com/ylab.php features.remote_phonebook.flash_time = 10800 programablekey.2.type = 22 programablekey.2.label = Contacts programablekey.2.xml_phonebook = 0
If you do not use config files, here is how you put it in the GUI.
-
Here is what it loos like on a Yealink T42G
The Contacts Button:
The list (it gets sorted alphabetically by the phone automatically):
-
JB is checking to see if something extra is needed for v14 of FreePBX.
-
@dashrender's FreePBX 14 system did not have PHP pear-db installed. My FreePBX 14 install that was upgraded from FreePBX 13 did.
A untouched FreePBX 13 install had PHP pear-db installed.
I have not had time to spin up a new FreePBX 14 instance to check.
If the above spits out an XML error then you need to install PHP pear-db
yum install -y php-pear-DB
-
I know this post is a bit old. But it's been the closest I've gotten to this phonebook thing. I placed the file inside the pbx but when i navigate to the pbx.domain.com/ylab.php it shows a part of the script inside of it instead of the output.
Clearly just taking part of the script i got from the GETHUB instead of supplying me with the output requested.
Any ideas?
-
@SJ2020 : If you create a phpinfo.php file in the same location as ylab.php. Do you get a nicely formatted PHP Info page or just raw script?
phpinfo.php
<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>
-
@manxam said in Use a php file to create a dynamic Yealink Remote Address book of FreePBX extensions:
@SJ2020 : If you create a phpinfo.php file in the same location as ylab.php. Do you get a nicely formatted PHP Info page or just raw script?
phpinfo.php
<?php // Show all information, defaults to INFO_ALL phpinfo(); ?>
I can say with 100% certainty that PHP is not a problem if it is the FreePBX distro. If it is any other version of FreepBX, then , it could be anything.
FreePBX has that natively built in the GUI.
-
@SJ2020 said in Use a php file to create a dynamic Yealink Remote Address book of FreePBX extensions:
I know this post is a bit old. But it's been the closest I've gotten to this phonebook thing. I placed the file inside the pbx but when i navigate to the pbx.domain.com/ylab.php it shows a part of the script inside of it instead of the output.
Clearly just taking part of the script i got from the GETHUB instead of supplying me with the output requested.
Any ideas?
You need to use the updated version.
https://github.com/sorvani/freepbx-helper-scripts/blob/master/Extensions_to_Yealink_AddressBook/ylab.php -
https://github.com/sorvani/freepbx-helper-scripts/blob/master/Extensions_to_Yealink_AddressBook/ylab.php is still working as of 11.3.2022. My FreePBX extension names contained the "&" which is a reserved symbol in XML and will throw an error in the script. If you run into this, the fix is below.
Simple fix is to edit this line:
echo " <Name>" . $extension['description'] . "</Name>\n";to this:
echo " <Name>" . htmlspecialchars($extension['description']) . "</Name>\n";