[Asterisk-Users] How do i configure so an incoming call triggers
an http request?
Alastair Maw
asterisk at almaw.com
Wed Aug 13 03:48:08 MST 2003
Dave Wilson wrote:
> I basically want asterisk to request an uri on our intranet, which will pass
> call details to our application and consequently store call details in a MS
> SQL Server database. Of course, if there are tools available for directly
> interacting with the database via odbc, then that would be excellent,
> however we still want to be able to trigger http requests for various other
> features.
It's not terribly efficient (starts up a Perl interpreter for every
incoming call), but you can do this with AGI, something like:
extensions.conf
---------------
[default]
s,1,AGI(log-call.pl)
log-call.pl
-----------
#!/usr/bin/perl
use DBI;
use Asterisk::AGI;
my $agi = new Asterisk::AGI;
my $dbh = DBI->connect('DBI:mssql:database:hostname', 'user', 'pass') or
die %DBI::errstr;
my $clid = $agi->get_variable('CALLERID');
my $dnid = $agi->get_variable('DNID');
my $add_date = time();
$sql = "INSERT INTO call (call_from, call_to, add_date) values
('$myclid', '$mydnid', FROM_UNIXTIME($add_date));";
$sth = $dbh->prepare($sql) or die $sth->errstr();
$sth->execute() or die $sth->errstr();
$dbh->disconnect();
Sort of thing. Obviously you could use LWP or similar in Perl to do HTTP
GETs, or just write a bash script which used wget to do an HTTP GET,
which would be much more efficient.
--
Alastair Maw <al.maw at mxtelecom.com>
MX Telecom - Systems Analyst
http://www.mxtelecom.com
More information about the asterisk-users
mailing list