ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Use a php file to create a dynamic Yealink Remote Address book of FreePBX extensions

    IT Discussion
    freepbx yealink extensions how to real instructions
    6
    12
    7.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by JaredBusch

      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 or nano. 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
      0_1512491267105_f6e18b16-256d-478a-acdb-6ad5893d645a-image.png

      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.
      0_1512491865082_e915f5de-1d00-45f9-b4fb-26e692661a57-image.png

      0_1512491929812_85865d90-fb69-47e9-954a-4b63b5894993-image.png

      1 Reply Last reply Reply Quote 5
      • JaredBuschJ
        JaredBusch
        last edited by JaredBusch

        Here is what it loos like on a Yealink T42G

        The Contacts Button:
        0_1512492823253_627a84b0-6394-49c5-bf85-daa4be6bf909-image.png

        The list (it gets sorted alphabetically by the phone automatically):
        0_1512492846824_a10460af-7278-4350-a999-fa0bcd5d6e61-image.png

        1 Reply Last reply Reply Quote 2
        • DashrenderD
          Dashrender
          last edited by

          JB is checking to see if something extra is needed for v14 of FreePBX.

          1 Reply Last reply Reply Quote 0
          • JaredBuschJ
            JaredBusch
            last edited by JaredBusch

            @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
            
            1 Reply Last reply Reply Quote 1
            • S
              SJ2020
              last edited by

              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.
              8aea824d-f07b-40b5-ab3f-bf210d3d579c-image.png

              Clearly just taking part of the script i got from the GETHUB instead of supplying me with the output requested.

              Any ideas?

              M JaredBuschJ 2 Replies Last reply Reply Quote 0
              • M
                manxam @SJ2020
                last edited by

                @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();
                
                ?>
                
                JaredBuschJ 1 Reply Last reply Reply Quote 0
                • JaredBuschJ
                  JaredBusch @manxam
                  last edited by JaredBusch

                  @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.
                  1b2ca519-db8e-4cad-b667-b01e4b249149-image.png

                  1 Reply Last reply Reply Quote 0
                  • JaredBuschJ
                    JaredBusch @SJ2020
                    last edited by

                    @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.
                    8aea824d-f07b-40b5-ab3f-bf210d3d579c-image.png

                    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

                    1 Reply Last reply Reply Quote 1
                    • D
                      DavidMo
                      last edited by

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

                      M 1 Reply Last reply Reply Quote 3
                      • M
                        Mistborn25 @DavidMo
                        last edited by

                        Is this script still working in FreePBX16?

                        I have this one and the similar cm_to_yl_ab.php script installed on by Freepbx server in /var/www/html/

                        My Freepbx server and the yealink phone are on a separate voice vlan with phones connected to vlan by LLDP. My http provisioning server on freepbx is working fine with dhcp option 66.
                        Initially I could not access the xml output from my native vlan, but after changing permissions to 777 for the php files I could view them in the browser and they appear to be working properly.
                        When I try to load them on the Yealink T54W phone either by EPM or directly through the phone GUI, I cannot get the address books to load. It thinks about it for awhile and then says failed to load address book.

                        What could be blocking me from loading this on the phone when it works in the browser?

                        M 1 Reply Last reply Reply Quote 0
                        • M
                          Mistborn25 @Mistborn25
                          last edited by

                          I figured part of it out, my provisioning server is using http with authentication. I was trying to download these files from the phone with http. Switched to https and it works now.

                          Now I can't figure out how to auto provision the remote phonebooks into the t54w phones. I am using EPM from sangoma and editing the base config file

                          features.remote_phonebook.enable = 1
                          features.remote_phonebook.flash_time = 10800

                          URL and name of phonebook

                          remote_phonebook.data.1.url = https://192.168.1.10/ylab.php
                          remote_phonebook.data.1.name = Internal

                          That was not working and I read in yealink instructions to add this favorite_setting.xml file with remote phonebook enabled and point config to it

                          directory_setting.url = https://192.168.1.10/favorite_setting.xml

                          Still not working. When I auto provision the phone the remote phonebook setting is not enabled and the remote addresses are blank.

                          1 Reply Last reply Reply Quote 0
                          • M
                            Mistborn25
                            last edited by

                            Finally got this working, reporting my issues here incase someone with similar issues stumbles upon this thread.

                            The T54W phones would not download the xml files by https (may be because I do not have a valid certificate setup). I could via the xml files in browser on https but phones would wait awhile and fail.
                            I am doing auto provisioning via http, but my default admin port was set to 8080. I could not download xml files via http with admin port on 8080.
                            Once I changed the admin port back to default 80, I was able to download xml files via http.
                            Phones can now download the php/xml files via http.
                            I changed permissions for the php files back to rw/rw/r with owner asterisk:asterisk

                            Auto Provisioning was another headache. Eventually I found out that I had the config settings wrong, was using features.remote_phonebook.data.1.url instead of the correct remote_phonebook.data.1.url

                            My working basefile edits (using EPM):

                            directory_setting.remote_phone_book.enable = 1
                            remote_phonebook.data.1.name = Internal
                            remote_phonebook.data.1.url = http://<pbx-ip>/ylab.php
                            features.remote_phonebook.enable = 1
                            remote_phonebook.data.2.name = External
                            remote_phonebook.data.2.url = http://<pbx-ip>/cm_to_yl_ab.php
                            

                            With directory_setting.remote_phone_book.enable = 1
                            You do not need the favorite_settings.xml to enable the remote directory. But it will put local directory as the first option and remote phonebook as the second option after hitting the directory key.

                            I have added this code to change the order:

                            directory_setting.local_directory.priority = 2
                            directory_setting.remote_phone_book.priority = 1
                            

                            Or to get rid of the local directory

                            directory_setting.local_directory.enable = 0
                            

                            Yealink has a Config Parameter Excel file that has all the config parameters and reading it is what lead me to find my mistake.

                            1 Reply Last reply Reply Quote 1
                            • 1 / 1
                            • First post
                              Last post