Matthew Simpson
2004-Jul-01 10:08 UTC
[Asterisk-Users] DISA and AGI: authenticate by caller ID?
I'm having trouble getting an AGI exec command to spawn app_disa. The script executes properly, but does not spawn DISA. The CLI gives no helpful clues. Am I doing the exec incorrectly? I want to have a way to authenticate callers to the extension by Caller ID... if their caller ID is in my database and set to active, they can call out. [like a calling card but auth'd by CID instead of PIN]. Here is my dialplan: 1234, 1, agi(ldusers.agi) 1234, 2, Hangup Here is my code: #!/usr/bin/perl # use Asterisk::AGI; use DBI; $db = "dbname"; $host = "hostname"; $port = "3306"; $userid = "dbuser"; $password = "dpasswd"; $connectionInfo = "DBI:mysql:database=$db;$host:$port"; $dbh = DBI->connect($connectionInfo,$userid,$password); $AGI = new Asterisk::AGI; my %input = $AGI->ReadParse(); $AGI->answer(); if (my $callerid = $input{'callerid'}) { $AGI->say_digits($callerid); $query = "SELECT active FROM cids WHERE cid=$callerid"; # active should be 1 if the caller ID is found and set active $sth = $dbh->prepare($query); $sth->execute(); $sth->bind_columns(undef, \$active); $sth->fetch(); if($active) $AGI->exec('DISA','no-password|disa'); } $AGI->hangup(); exit;
Nicolas Gudino
2004-Jul-01 11:08 UTC
[Asterisk-Users] DISA and AGI: authenticate by caller ID?
Hi Matthew, Look at the bootom for my recommendation (take note, I did not test it): On Thu, 2004-07-01 at 14:08, Matthew Simpson wrote:> I want to have a way to authenticate callers to the extension by Caller > ID... if their caller ID is in my database and set to active, they can call > out. [like a calling card but auth'd by CID instead of PIN]. > > Here is my dialplan: > > 1234, 1, agi(ldusers.agi) > 1234, 2, Hangup > > Here is my code: > > #!/usr/bin/perl > # > > use Asterisk::AGI; > use DBI; > > $db = "dbname"; > $host = "hostname"; > $port = "3306"; > $userid = "dbuser"; > $password = "dpasswd"; > $connectionInfo = "DBI:mysql:database=$db;$host:$port"; > $dbh = DBI->connect($connectionInfo,$userid,$password); > > > $AGI = new Asterisk::AGI; > > my %input = $AGI->ReadParse(); > > $AGI->answer(); > > if (my $callerid = $input{'callerid'}) { > > $AGI->say_digits($callerid); > $query = "SELECT active FROM cids WHERE cid=$callerid"; # > active should be 1 if the caller ID is found and set active > $sth = $dbh->prepare($query); > $sth->execute(); > $sth->bind_columns(undef, \$active); > $sth->fetch(); > > if($active) > $AGI->exec('DISA','no-password|disa');^^^^^ Instead of executing the application, try creating a new context in your dialplan that executes DISA. You can send the call to that context like this: $AGI->set_context("disa"); $AGI->set_extension("s"); $AGI->set_priority(1);> } > > $AGI->hangup(); > > exit;In extension.conf add the disa context like this: [disa] exten => s,1,disa,no-password|disa This way, if an error happens with DISA, it will be displayed at the asterisk console (it will not be hidden inside AGI). Good luck, -- Nicolas Gudino <nicolas@house.com.ar> House Internet S.R.L.
awesome@surfbest.net
2004-Jul-01 11:50 UTC
[Asterisk-Users] DISA and AGI: authenticate by caller ID?
matthew, I'm still in New orleans. If you get this email before 5pm, give me a a call 504-833-4806. Ron wynn ---- Original Message ---- From: matthew@txlink.net To: asterisk-users@lists.digium.com Subject: RE: [Asterisk-Users] DISA and AGI: authenticate by caller ID? Date: Thu, 1 Jul 2004 12:08:56 -0500>I'm having trouble getting an AGI exec command to spawn app_disa. >The >script executes properly, but does not spawn DISA. The CLI gives no >helpful >clues. Am I doing the exec incorrectly? > >I want to have a way to authenticate callers to the extension by >Caller >ID... if their caller ID is in my database and set to active, they >can call >out. [like a calling card but auth'd by CID instead of PIN]. > >Here is my dialplan: > >1234, 1, agi(ldusers.agi) >1234, 2, Hangup > >Here is my code: > >#!/usr/bin/perl ># > >use Asterisk::AGI; >use DBI; > >$db = "dbname"; >$host = "hostname"; >$port = "3306"; >$userid = "dbuser"; >$password = "dpasswd"; >$connectionInfo = "DBI:mysql:database=$db;$host:$port"; >$dbh = DBI->connect($connectionInfo,$userid,$password); > > >$AGI = new Asterisk::AGI; > >my %input = $AGI->ReadParse(); > >$AGI->answer(); > >if (my $callerid = $input{'callerid'}) { > > $AGI->say_digits($callerid); > $query = "SELECT active FROM cids WHERE cid=$callerid"; > # >active should be 1 if the caller ID is found and set active > $sth = $dbh->prepare($query); > $sth->execute(); > $sth->bind_columns(undef, \$active); > $sth->fetch(); > > if($active) > $AGI->exec('DISA','no-password|disa'); > >} > >$AGI->hangup(); > >exit; > >_______________________________________________ >Asterisk-Users mailing list >Asterisk-Users@lists.digium.com >http://lists.digium.com/mailman/listinfo/asterisk-users >To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users