GO HERE Asterisk Phonebook integration for Cisco Phones

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz thanks for the response, any ideas on what that minor modification would look like?

The example provided by Stefan Gofferje seems to be in the right direction, the command "sudo /usr/sbin/asterisk -rx "database show cidname"" does output the contents of the Phonebook database on the Asterisk command line but unfortunately this information does not seem to be displayed when executed on the phone, there are no errors displayed on the handset so I am guessing the php is parsed correctly.
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz, again thanks for your time, the original script displaying the "users" works well.

When I replace the two lines with the additional code you have supplied I see nothing displayed on the phone, I have tried un-commenting the "print_r...." but also nothing, i'm unsure where this debug information should be stored or displayed?

Excuse my ignorance as i am not a php programmer or experienced in sql, but if we were able to find where the table was stored for the "phonebook". Then could we not just then change the sql statement to something like this (assuming that the table is in the same format)

$sql = "SELECT name,extension FROM phonebook_list ORDER BY extension";
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
I have uploaded my config, could please check if i have missed something
 

Attachments

  • Directory.txt
    3.3 KB · Views: 51

tm1000

Schmoozecom INC/FreePBX
Joined
Dec 1, 2009
Messages
1,360
Reaction score
78
htmlentities will save you there. Those characters need to be html encoded. Remember that html is essentially xml in the end.
Seems to work fine for me when I test with a browser, tho I just discovered that special characters in the name such as & < > throw errors. I think we have exhausted what little I can do without a Cisco phone. hbonath do you have anything to add here?
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
OK, this seems strange, I tried the script via my browser and got the "Requires FreePBX Phonebook module" message, see attached screenshot. but the asterisk phone book is installed, note the original script "spadir.php" also works via the browser.

I am running Asterisk 11.7.0 and freePBX 2.11.0.23
 

Attachments

  • Screen Shot.JPG
    Screen Shot.JPG
    49.2 KB · Views: 34

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz, I tried this on another asterisk (11.3.0-rc1 with freePBX 2.11.0.25) and it behaved in the same way. I have attached a screenshot indicating the installed modules. Below is the output of "database show cidname" indicating that there are entries in the database

PBX*CLI> database show cidname
/cidname/1234567 : pescatore
/cidname/56987512 : Testing
/cidname/98765432 : Test Number
3 results found.
PBX*CLI>

Thank you for your time on this
 

Attachments

  • Modules.JPG
    Modules.JPG
    159.1 KB · Views: 31

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
Very annoying, I am running Asterisk on a Raspberry PI but I don't believe that would be an issue. I will try this script on some different hardware on Monday to see if that makes a difference. I assume the phonebook_list() function does not rely on any other libraries or modules?
 
Joined
May 22, 2013
Messages
301
Reaction score
44
I reckon I can help you.

Check out my resource tutorial at http://pbxinaflash.com/community/index.php?resources/cisco-7900-series-tutorial-v1-1.25/ - part 8 is what you're looking at. I have written this in mind with Asteridex rather than the Asterisk directory purely because it's a little easier to administer. If you do have a go at this also read the update tab on my tutorial as there's a bug meaning some slightly incorrect code but my update explains it all.

Good luck, I was working totally in the dark but I reckon you'll be able to figure it if you go carefully over my tutorial.
 

Al Grant

Member
Joined
Jun 4, 2014
Messages
30
Reaction score
0
I got it to import contacts into asteridex and connect that to my 7941 - cool.

I am in country code "64" but all the imported numbers show on the phone with a leading "9" (they don't have this 9 in asteridex).

Where did the "9" come from?

Cheers

-Al
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz, apologies for bringing this up again. I finally had some time to look at this again today. I noticed that I was unable to find any installed module functions using the freepbx Bootstrap, i.e. installed modules located within /var/www/html/admin/modules. I ran the following script below:

<?php
// load FreeBPX bootstrap environment, requires FreePBX 2.9 or higher
if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
include_once('/etc/asterisk/freepbx.conf');
}

// set FreePBX globals
global $db; // FreePBX asterisk database connector
global $amp_conf; // array with Asterisk configuration
global $astman; // AMI

// if (function_exists('ast_with_dahdi')) { //Success "/var/www/html/admin/functions.inc.php"
// if (function_exists('get_instance')) { //Success "/var/www/html/admin/functions.inc.php"
// if (function_exists('get_headers_assoc')) { //Success "/var/www/html/admin/functions.inc.php"
// if (function_exists('freepbx_log')) { //Success "/var/www/html/admin/libraries/utility.functions.php"
// if (function_exists('write_voicemailconf')) { //fails "/var/www/html/admin/libraries/voicemail.function.php"


// if (function_exists('ringgroups_destinations')) { //fails "/var/www/html/admin/modules/ringgroups/functions.inc.php"
// if (function_exists('announcement_destinations')) { //fails "/var/www/html/admin/modules/announcement/functions.inc.php"
// if (function_exists('get_filename')) { //fails "/var/www/html/admin/modules/core/functions.inc.php"
if (function_exists('vmxObject')) { //fails "/var/www/html/admin/modules/voicemail/functions.inc.php"

echo 'Function Found';
} else {
// echo $amp_conf['AMPWEBROOT']; //Echoes the webroot
// echo $dirname;
//echo 'Requires FreePBX Phonebook module';
echo 'Could not find Function';
}
//END
?>

As can be seen I tried a selection of functions and all those located within the “modules” folder failed, functions located in other locations seems to be successful.

So my assumption is that the Bootstrap has an issue with loading them? Or is there a setting somewhere to have these included?

Could you shed some light on how these functions are called? Or point me in the right direction to get this resolved?
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz, i was unable to find the class or method when adding your code to the script, so it seems for me that the Bootstrap is not loading the modules, or am i missing smething here?
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
lgaetz, OK i am unsure what is going on but i have now been able to find the "phonebook_list" function and seems the code you provided above "Aug 29th" is now working for me, Thanks!!!!!

The issue for me is i think that the Bootstrap is unable to load the installed module functions for some reason. I amended the config so that the function was called directly.

In "/var/www/html/admin/functions.inc.php" i added the following line

//Test - Call the phonebook function directly
require_once($dirname . '/modules/phonebook/functions.inc.php');

In "/var/www/html/admin/modules/phonebook/functions.inc.php" i commented the following line:

<?php /* $Id */
// if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
// License for all code of this FreePBX module can be found in the licensefile inside the module directory

I have think i have just masked the real issue, but i am unsure how to resolve it correctly?
 

hbonath

Guru
Joined
Jan 24, 2012
Messages
150
Reaction score
40
Great thread guys, I've never used Asterisk Phonebook before (I'm guessing I should!) so I haven't tried rolling that code back into the directory script. (I'm definitely *not* a developer! Just tinkering here!)
I'm a big fan of the SPA phones, I've been doing some heavy evaluation on those vs. Yealink and had an epic fail trying to port the "spadir.php" to work on Yealink's XML - I'll probably start a new thread on that one, mega side-note there.

Let me know if I can help here, I'll do the best I can
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1
When the number of contacts exceeded 32 I noticed that we get "XML Error [4]: Parse Error" on Cisco 79xx, 89xx & 99xx models.

This was due to the script trying to display 33 contacts per page.

I have amended the following line and this is now working on Cisco 79xx, 89xx & 99xx models:

$count = $page * 32 ;
for ($row=$count; $row <= $count+31; $row++) { //amended from 32 to 31
if (is_null($results[$row][0])) {
$endoflist = True;
 

Pescatore

New Member
Joined
Jan 14, 2014
Messages
20
Reaction score
1

Attachments

  • Search.txt
    3.6 KB · Views: 21

Members online

Forum statistics

Threads
25,782
Messages
167,514
Members
19,203
Latest member
frapu
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top