[Asterisk-Users] AGI and set_callerid for number and name
Serge Lhermitte
serge at arubanetworks.com
Thu Oct 13 00:37:19 MST 2005
Thanks a lot.
S.
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Pedro
Nunes
Sent: mercredi 12 octobre 2005 19:18
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: RE: [Asterisk-Users] AGI and set_callerid for number and name
Curse,
Look at this php script ...
Contactlookup.agi
#!/usr/local/bin/php -q
<?php
ob_implicit_flush(true);
set_time_limit(6);
$in = fopen("php://stdin","r");
$stdlog = fopen("/var/log/asterisk/my_agi.log", "w");
// toggle debugging output (more verbose)
$debug = true;
// Do function definitions before we start the main loop
function read() {
global $in, $debug, $stdlog;
$input = str_replace("\n", "", fgets($in, 4096));
if ($debug) fputs($stdlog, "read: $input\n");
return $input;
}
function errlog($line) {
global $err;
echo "VERBOSE \"$line\"\n";
}
function write($line) {
global $debug, $stdlog;
if ($debug) fputs($stdlog, "write: $line\n");
echo $line."\n";
}
// parse agi headers into array
while ($env=read()) {
$s = split(": ",$env);
$agi[str_replace("agi_","",$s[0])] = trim($s[1]);
if (($env == "") || ($env == "\n")) {
break;
}
}
// main program
echo "VERBOSE \"Here we go!\" 2\n";
read();
$session = mssql_connect('mssql server' , 'username' , 'password' );
$result = mssql_query("select * from ContactDB WHERE
extension=".$agi['callerid'],$session );
$row = mssql_fetch_array($result);
mssql_close($session);
if ($row['Name'] == ""){
write('SET VARIABLE NAME "Not Found"');
read();
} else {
write('SET VARIABLE NAME "'.$row['Name'].'"');
read();
}
fclose($in);
fclose($stdlog);
And in extensions.conf
[extensions]
exten => 4501,1,agi,contactlookup.agi
exten => 4501,2,SetCIDName(${Name})
exten => 4501,3,Dial(SIP/421,15)
It looks to an mssql DB, try to find the callerID number in table
"extensions", and then sets a variable named "Name" to the value of
table "Name". Cool hah...
Pedro Nunes
-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Serge
Lhermitte
Sent: quarta-feira, 12 de Outubro de 2005 17:57
To: asterisk-users at lists.digium.com
Subject: [Asterisk-Users] AGI and set_callerid for number and name
Hi,
I've been trying to use the set_callerid function in the AGI. It sets
the CallerIDname properly but I can't figure out how to set the
CallerIDnumber.
Is it at at possible ?
Cheers.
SL
_______________________________________________
--Bandwidth and Colocation sponsored by Easynews.com --
Asterisk-Users mailing list
Asterisk-Users at 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
_______________________________________________
--Bandwidth and Colocation sponsored by Easynews.com --
Asterisk-Users mailing list
Asterisk-Users at 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
More information about the asterisk-users
mailing list