<html><head><style type="text/css"><!-- DIV {margin:0px} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>This is the code I wrote to do that job, without getting into the full phpagi:<br><br><br>function readManagerResponse($resp, $lookFor) {<br> $value_start = strpos($resp, $lookFor) + strlen($lookFor); <br> $value_stop = strpos($resp, "\r\n", $value_start); <br> if (strpos($resp, $lookFor) === FALSE ){ <br> echo "ERROR: readManagerResponse() didn't find $lookFor in $resp<br>"; return FALSE;<br> } else {<br> $hold = substr($resp, $value_start, $value_stop - $value_start); return $hold;<br> }<br>}<br><br>function goodResponse($resp){ <br> $stat =
readManagerResponse($resp, "Response: ");<br> if ($stat === FALSE) {}<br> return ($stat == "Success");<br>}<br><br><br>=== open a connection to Manager on $fp, and get logged in====<br><br>fputs ($fp, "Action: DBget\r\n");<br>fputs ($fp, "Family: webdialer\r\n");<br>fputs ($fp, "Key: $thingImLookingFor\r\n\r\n");<br>sleep(2) ;<br>$resp = null;<br>
do {<br>
$line = fgets($manager, 4096);<br>
$resp .= $line;<br>
} while (($line != "\r\n") && ($line));<br>if (goodResponse($resp)) { // If the key exists, get the value<br> $resp = getFromManager($fp);<br> $callercontext = readManagerResponse($resp,"Val: ");<br> echo "Using database value $callercontext as context.<br>\r\n";<br>} else {<br> echo "No database entry, or couldn't authenticate to the AstDB.<br>\r\n"; <br> echo "Caller will instead use $defaultContext context.<br>\r\n"; <br> $callercontext = $defaultContext;<br>}<br><br>Hope that helps,<br>--JW<br><br>----- Original Message ----<br>From: Darren Ellis <darren@ieworks.net><br>To: Asterisk Users Mailing List - Non-Commercial Discussion <asterisk-users@lists.digium.com><br>Sent: Sunday, April 9, 2006 7:23:18 PM<br>Subject: [Asterisk-Users] Manager API Help<br><br><div>Hi All,<br><br>Could someone send
me a code frag on how to get a record from the <br>asterisk database into a PHP variable via the Manager API?<br><br>I can issue calls, etc. from Manager. But I'm not comprehending how to <br>manipulate database variables.<br><br>Thanks much.<br><br>Darren Ellis<br><br>_______________________________________________<br>--Bandwidth and Colocation provided by Easynews.com --<br><br>Asterisk-Users mailing list<br>To UNSUBSCRIBE or update options visit:<br> <a target="_blank" href="http://lists.digium.com/mailman/listinfo/asterisk-users">http://lists.digium.com/mailman/listinfo/asterisk-users</a><br></div></div></div></div></body></html>