DB integration & dialling

Talk with others about developing applications for Switchvox

Moderators: bmdhacks, dpodolsky, tristand, jwitt, joshuas

DB integration & dialling

Postby jibbler » Thu Jun 25, 2009 7:47 pm

Hi,

I have got a HTML/PHP page hosted on an (not that it matters) Apache/Ubuntu server. The page queries an LDAP (MS2K3 DC) for names, addresses, phone numbers of users. I've got a panel in Switchboard showing this information correctly. The fact that this is LDAP is pretty irrelevant - it could be retrieving the data from MySQL or any other source but it will be displayed on a web page.

What I want to do is create a hyperlink for the phone number field to dial that person. During the db query, the phone number is put in to a variable called eg $phonenum. I can create a link in the PHP for

https://ip.address.of.swvx/api?call&dia ... =$phonenum

or

https://ip.address.of.switchvox/api?cmd ... ial_as=400

but the problem is that the 'dial_as' or 'dial_first' fields must be fixed (in those cases it's 400). That means that if I'm logged in to Switchboard as 400 then it will work but not if I'm any other user.

Somehow I need to get a variable which is whatever xtn the user is logged in to Switchboard with. I don't believe this can be done with a cookie as the cookie is supplied by the Switchvox Apache server and my PHP page is hosted on another server.

Does anyone know if this is possible and/or have a way doing it?

Thx
jibbler
Oldsterisk
 
Posts: 121
Joined: Thu Jun 25, 2009 7:20 pm

Postby dpodolsky » Fri Jun 26, 2009 10:19 am

I think I have your solution. If you look at the WIKI documentation for the Switchboard Panels overview, at the bottom is the list of variables you can use in your Custom Panel URL:

http://developers.digium.com/switchvox/wiki/index.php/SwitchboardPanels_overview

Then variable you want to use in your custom Switchboard panel url is "EXTENSION" which is the extension of the current Switchboard user. When you create your webpage you can just swap in this variable for the one in your call creation url and it will be the extension of the person logged in.

Here is a sample URL that I see you using:
http://www.example.com/mywebservice?extension=%EXTENSION%


Let me know if this works for your custom panel.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Postby jibbler » Sun Jun 28, 2009 4:57 pm

I'm not sure if you're not reading what I want to do or whether I'm not explaining it clearly.

The link I want to use is along the lines of

https://ip.address.of.swvx/api?call&dia ... =$phonenum

whereas you've got a link as if it's an incoming call and it's going to a script to react to that call. That is not the scenario I'm looking at. This is when the phone is at idle and wants to dial out.

I have tried using the variable you mention without success

https://ip.address.of.swvx/api?call&dial_first=%extension%&dial_second=$phonenum ($phonenum is a variable from my db)

It does attempt to do something but looks as though it is not logged in and presents the following error

ERROR: ERROR: syntax error at or near "%" at character 42
ERROR: syntax error at or near "%" at character 42
Click the link below to log into the online user suite: Login

The 'Login' is a link that takes me to the the following address
https://ip.address.of.switchvox/main?cm ... sion=&url=
jibbler
Oldsterisk
 
Posts: 121
Joined: Thu Jun 25, 2009 7:20 pm

Postby dpodolsky » Sun Jun 28, 2009 8:59 pm

Sorry Jib let me try to clear things up from my previous post. I didn't mean to use "%EXTENSION%" in your call URL, but instead it should go in your Switchboard panel URL.

So in your PBX if you navigate to Admin -> Switchboard Plugins you need to change the URL of your custom panel to have "%EXTENSION%" in it. Something like this:

http://your.ubuntu.server/your_switchboard_panel_php_script.php?extension=%EXTENSION%



Then in your PHP script you will parse the cgi variable and use it to generate your links. Maybe something like this:

your_switchboard_panel_php_script.php
$extension = $_GET['extension'];
$url = "https://ip.address.of.swvx/api?call&dial_first=$extension&dial_second=$phonenum"


This clear things up?
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Postby jibbler » Mon Jun 29, 2009 6:23 pm

Yes, a bit more sense now :) Apart from the typo in the link you gave
$url = "https://ip.address.of.swvx/api?cmd=call&dial_first=$extension&dial_second=$phonenum

However, still not having any luck getting it to work. I then decided to go back to real basics and build it up. And found that my my script works but not in the Switchboard.

Here's why I've done - this is about as simple as it can be. This is my test.php code

Code: Select all
<html><body>
<?php
$extension = $_GET['extension'];
?>
Your extension number is <?php echo $extension ?> <br />
<a href="http://ip.address.of.switchvox/api?cmd=call&dial_first=<?php echo $extension ?>&dial_second=4003">Call 4003</a>
</body></html>


My Switchboard panel is set to http://ip.address.of.webserver/test.php?extension=%extension%

When I browse to (not in Switchboard) http://ip.address.of.webserver/test.php?extension=4008 I get the correct details displayed ie

Your extension number is 4008
Call 4003

and the link on the 'Call 4003' correctly shows http://ip.address.of.switchvox/api?cmd= ... econd=4003

So that proves that the very simple script is taking the %extension% parameter and putting it in the correct place.

However, when loading Switchboard it shows this

Your extension number is %extension%
Call 4003

and the link on the 'Call 4003' in correctly shows http://ip.address.of.switchvox/api?cmd=call&dial_first=%extension%&dial_second=4003

The script that links the LDAP DB is quite complicated so I won't bother getting in to that here. But this simple (it couldn't be any simpler if anyone tried) shows that the parameters work correctly in a browser but not in Switchboard.

Any ideas why?
jibbler
Oldsterisk
 
Posts: 121
Joined: Thu Jun 25, 2009 7:20 pm

Postby dpodolsky » Mon Jun 29, 2009 6:38 pm

Make sure its not a case issue. Instead of %extension% try %EXTENSION% in your panel URL and see if that changes anything.
dpodolsky
Oldsterisk
 
Posts: 325
Joined: Thu Apr 23, 2009 2:35 pm

Postby jibbler » Mon Jun 29, 2009 6:42 pm

Good ol' Linux and it's case sensitivity :( That works now.

I'll go back to the original code for the DB integration and see if it works.
jibbler
Oldsterisk
 
Posts: 121
Joined: Thu Jun 25, 2009 7:20 pm


Return to Switchvox Developers

Who is online

Users browsing this forum: No registered users and 1 guest