SOLVED XML Phonebook

Status
Not open for further replies.

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
We've decided to include the XML phonebook in our provisioning of our GXP2130 and 60 phones. FusionPBX doesn't come with the files to support that, so here's a basic one we made that works with extensions, first and last names, and contact photos. Create a file called "phonebook.xml" in each grandstream provisioning profile folder of the profiles you use, and insert the contents below. One could modify this even more so it takes advantage of the <accountindex> tag and assign contacts to the respective extension when multiple extensions are configured on the phone.

<?xml version="1.0" encoding="UTF-8"?>
<AddressBook>
{foreach $contacts as $contact}

<Contact>
<LastName>{$contact.contact_name_family}</LastName>
<FirstName>{$contact.contact_name_given}</FirstName>
<Phone>

<phonenumber>{$contact.phone_extension}</phonenumber>
<accountindex>1</accountindex>
</Phone>
<PhotoUrl>http(s)://your_server/some_path/{$contact.phone_extension}.jpg</PhotoUrl>
</Contact>
{/foreach}
</AddressBook>
 
Last edited:
  • Like
Reactions: Scott Williams

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
I would think it's possible... While we do have contacts in our Contacts app in FusionPBX, but they don't show up in our contact provisioning. They're not very important to us, so I haven't researched to see what's needed to include them.
 
  • Like
Reactions: Scott Williams
Feb 18, 2017
44
7
8
63
Thanks for the quick response! Where did you get the field listing, like this: $contact.phone_extension?

I'll play with this soon on my lab system.
 

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
Hmm... Good question! I don't remember how I found that one in particular. It was probably from some other phonebook provisioning file that came with FusionPBX, or I made some temporary edits to the respective PHP file(s) that would tell me everything about the $contacts variable.

PHP help is outside of the scope of this forum, but here's two tips to get you started: 1) Using print_r(<var>, true) and file_put_contents() is a simple method of telling you about the variable that won't affect the output of the provisioning file. 2) Just from a quick glance, it looks like <fpbx dir>/app/provision/index.php or <fpbx dir>/app/provision/resources/classes/provision.php would be the files to look at if you're wanting to go with the temporary PHP file edits.

Best of luck to you! Make sure to share your finding here so others can benefit, too.
 
Feb 18, 2017
44
7
8
63
Great detailed reply! I was under the impression that you were using the FPbx contacts app. So where are you getting the contacts data from?

I saw a Cisco system that has an internal directory on the phones, I think that is what I am trying to accomplish.

-Scott
 

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
We're just generating it from the extensions on the system. To do so, in Default Settings set "contact_extensions" (in the Provision section) to true to use the local extensions.
 
Feb 18, 2017
44
7
8
63
Ok, in my lab, I have a GXP2130, so created the file as you specified, but it doesn't seem to add the phonebook to the phone. Do I have to enable something somewhere else? I even changed the lua file to resync like in your other post and changed the contact_extensions. Thx.

Do I have to turn something on in the GXP2130? I see fields for Phonebook server, etc.
 
Last edited:
Feb 18, 2017
44
7
8
63
Caleb,

Did you happen to write the code that is now included with Fusion?

I can't get it working and Mark says he didn't write it.

Basically, on the Devices page, I can download the phonebook XML file, so I know it is generating it correctly.

Here's what happens when I press the Download phonebook button on the phone:
"GET /app/provision/pb000b8297844e/phonebook.xml HTTP/1.1" 401 23 "-" "Grandstream Model HW GXP2130 SW 1.0.9.69 DevId 000b8297844e"

Under the provision folder, there is no folder for my phone. /provision/pb000b8297844e for example.

Thanks,
Scott

P.S. I am now on Fusion 4.4
 
Last edited:

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
I think I made some contributions to the code repository, but not much. I also haven't used FPBX 4.4 (in testing or production) so there may be other changes there outside of the contributions I made that might be causing issues.

However, the error you included is somewhat telling... The 401 response code means "Unauthorized," so make sure you haven't configured anything in the web server config or in FPBX that requires clients to authenticate themselves. Not as likely the be the issue here, but make sure the proper redirect rule for the phonebook is in place. We use the nginx web server (default for FPBX) on a Debian 8 machine, and our config includes:
rewrite "^.*/provision/pb([A-Fa-f0-9-]{12,17})/phonebook\.xml$" /app/provision/?mac=$1&file=phonebook.xml;

I've never used it to troubleshoot authentication errors before, but you could also check the web server's error log to see if it has more details as to why it returned that response code.
 
Feb 18, 2017
44
7
8
63
Ok, thanks. Provisioning works fine. I did include the rewrite rule as you said. The output I sent was from the nginx access.log and nothing was corresponding in the error.log.

I'll keep digging, thanks for the quick response!
 

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
The output I sent was from the nginx access.log and nothing was corresponding in the error.log.
I don't have any ground for it right now, but the fact that there's nothing in the error.log seems to me like the web application (FPBX in this case) is the one that specified that response code instead of the web server, which points to FBPX being configured to require authentication of some sort...

Good luck!
 
Feb 18, 2017
44
7
8
63
Ok, so in Default Settings, there are two enabled settings for passwords, and both are enabled:

admin_password and http_auth_password

When I turned off http_auth_password, the phone would not provision, so I turned it back on.

Is there somewhere else I should be looking?
 

Caleb

Member
Sep 12, 2017
42
17
8
WA, USA
Make sure the phone is sending the correct credentials when getting the phonebook. Since the phonebook is accessed via the provisioning app, it would be the same username and password as that.
 
Feb 18, 2017
44
7
8
63
Thanks.

When I log into the phone and go to Phonebook Management I put the admin name and password in there, I get a 404. When I take the name and password out, I get a 401.

Maybe its a setting in nginx somewhere.
 
Feb 18, 2017
44
7
8
63
Log into phone, blank out user and password: 401
Log into phone, put in user and password:401
Log into phone, change to https setting, out in user and password: 404
Log into phone, change back to http, user - donald, password - duck: 401
 
Status
Not open for further replies.