inserting calls into sql server 2008 database?

Talk with others about developing applications for Switchvox

Moderators: bmdhacks, dpodolsky, tristand, jwitt, joshuas

inserting calls into sql server 2008 database?

Postby a1 » Wed Apr 25, 2012 12:54 pm

Greetings,

I'd like to know if it is possible to have switchvox insert calls into a database automatically (sql server 2008 preferred) in real time and what api calls are best suited to that purpose. A simple sql insert or an execution of a stored procedure would be great.

We have the most recent switchvox smb

Thanks
a1
Newsterisk
 
Posts: 2
Joined: Wed Apr 25, 2012 12:51 pm

Re: inserting calls into sql server 2008 database?

Postby sterlingmarking » Mon Apr 30, 2012 7:12 am

possible, use the event api, this is the only way that switchvox can initiate an external action. it uses xml via http, so you will have to write a custom web page that accepts and parses the xml packet to insert the desired data into switchvox, and then tell switchvox the URL of your custom page.

events are documented here: http://developers.digium.com/switchvox/wiki/index.php/UrlManagerAPI_events

xml packet structure is documented here: http://developers.digium.com/switchvox/wiki/index.php/UrlManagerAPI_xml
Jesse Carlton
Systems Administrator
Sterling Marking Products Inc.
sterlingmarking
Oldsterisk
 
Posts: 100
Joined: Mon Mar 22, 2010 9:42 am
Location: London, Ontario

Re: inserting calls into sql server 2008 database?

Postby KKiernan » Tue May 08, 2012 8:58 am

I'm just getting started with switchvox and did this as a test with incoming calls. I'm using PHP and MySQL but the concept is the same. Set up a switchvox event trigger (in your admin section) to call your application page (are you using ASP w/ SQL Server 2008?). I set up the "on incoming call" trigger to call my PHP file below passing it the caller id number and name like so:

http://www.domain.com/your_file.php?caller_id_number=%CALLER_ID_NUMBER%&caller_id_name=%CALLER_ID_NAME%


Code: Select all
<?php

   // Database connection
   $connection = mysql_connect('host','username','password');
   
   if (!$connection)
   {
      die(mysql_error());
   }
   
   // Choose database
   mysql_select_db('switchboard', $connection);
   
   // Get incoming caller data from switchvox
   $callerIdNumber   = $_GET['caller_id_number'];
   $callerIdName      = $_GET['caller_id_name'];
   
   // Insert caller data
   $insert = mysql_query("
      INSERT INTO IncomingCalls VALUES (
         NULL,
         $callerIdNumber,
         '$callerIdName',
         NOW()
      )
   ");

?>
KKiernan
Newsterisk
 
Posts: 7
Joined: Fri May 04, 2012 7:39 am

Re: inserting calls into sql server 2008 database?

Postby a1 » Wed May 09, 2012 8:06 pm

http://www.whatever.com/submitdid.cfm?C ... _ID_NUMBER%&%INCOMING_DID=%INCOMING_DID%


when I save event triggers the software rewrites my strings

and replaces & with &amp; , which breaks my application. Is there anyway to get the interface to the smb to leave the url string as it is?

We are using 5.1.2
a1
Newsterisk
 
Posts: 2
Joined: Wed Apr 25, 2012 12:51 pm

Re: inserting calls into sql server 2008 database?

Postby rnavaroli » Thu May 10, 2012 11:13 am

Do you mean Switchvox rewrites your urls or your web server is interpreting them like that. &mp; is a URL encoded ampersand and should not be used in variable names if that is what you are trying to do.

I am running SMB 5.5.3 and just performed the following test which all worked successfully.

http://my_server.com/tests/inc_call.php?caller_id=%CALLER_ID_NUMBER%&incoming_did=%INCOMING_DID%&name=%CALLER_ID_NAME%&extension=%EXTENSION%


My server's apache log saw the request come through accurately and looked like
GET /tests/inc_call.php?caller_id=102&incoming_did=&name=Jackie&extension=101 HTTP/1.0" 200 97 "-"...
rnavaroli
Newsterisk
 
Posts: 2
Joined: Thu May 10, 2012 10:09 am

Re: inserting calls into sql server 2008 database?

Postby sterlingmarking » Thu May 10, 2012 11:18 am

That definitely shouldn't happen. Try using a different browser, or open a support ticket.


The best advice would be to update to the latest release.
Jesse Carlton
Systems Administrator
Sterling Marking Products Inc.
sterlingmarking
Oldsterisk
 
Posts: 100
Joined: Mon Mar 22, 2010 9:42 am
Location: London, Ontario


Return to Switchvox Developers

Who is online

Users browsing this forum: No registered users and 1 guest