[Asterisk-Users] pass caller ID to another application or machine.

Michiel van Baak michiel at vanbaak.info
Mon Mar 28 05:55:30 MST 2005


On 04:07, Mon 28 Mar 05, Richard Reina wrote:
> DO you happen to rember the name of the agi command
> that thansfers the record into the table? Or do you
> know where I can find some sample sripts to look at?

Hi,

Here are some snippets from my php-based agi:

#!/usr/bin/php4 -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 = false;
// 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;
}
				
// 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;
	}
}
.........<snip>........
// lookup id and name
$sql = "SELECT a.id,a.bedrijfsnaam FROM adres as a,bcards as b WHERE a.id=b.bedrijfs_id AND (replace(replace(a.telnr,'-',''), ' ','') ILIKE '%".$agi["callerid"]."')"; 
.........<snip>........
// put the stuff into our table
$sql = "INSERT INTO active_calls VALUES ('".$row["bedrijfsnaam"]."',".$row["id"].",".mktime().")";
.........<snip>........
?>



have fun!
-- 
Michiel van Baak
http://lunteren.vanbaak.info
michiel at vanbaak.info
GnuPG key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x7E0B9A2D

"Two of the most famous products of Berkeley are LSD and BSD. I don't think that this is a coincidence."




More information about the asterisk-users mailing list