<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>&nbsp;&nbsp;&nbsp; $value_start = strpos($resp, $lookFor) + strlen($lookFor); <br>&nbsp;&nbsp;&nbsp; $value_stop = strpos($resp, "\r\n", $value_start); <br>&nbsp;&nbsp;&nbsp; if (strpos($resp, $lookFor) === FALSE ){ <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; echo "ERROR: readManagerResponse() didn't find $lookFor in $resp&lt;br&gt;"; return FALSE;<br>&nbsp;&nbsp;&nbsp; } else {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $hold = substr($resp, $value_start, $value_stop - $value_start); return $hold;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br>function goodResponse($resp){ <br>&nbsp;&nbsp;&nbsp; $stat =
 readManagerResponse($resp, "Response: ");<br>&nbsp;&nbsp;&nbsp; if ($stat === FALSE) {}<br>&nbsp;&nbsp;&nbsp; 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>
&nbsp; &nbsp;&nbsp;&nbsp; do {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $line = fgets($manager, 4096);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $resp .= $line;<br>
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; } while (($line != "\r\n") &amp;&amp; ($line));<br>if (goodResponse($resp)) { // If the key exists, get the value<br>&nbsp;&nbsp;&nbsp; $resp = getFromManager($fp);<br>&nbsp;&nbsp;&nbsp; $callercontext = readManagerResponse($resp,"Val: ");<br>&nbsp;&nbsp;&nbsp; echo "Using database value $callercontext as context.&lt;br&gt;\r\n";<br>} else {<br>&nbsp;&nbsp;&nbsp; echo "No database entry, or couldn't authenticate to the AstDB.&lt;br&gt;\r\n"; <br>&nbsp;&nbsp;&nbsp; echo "Caller will instead use $defaultContext context.&lt;br&gt;\r\n"; <br>&nbsp;&nbsp;&nbsp; $callercontext = $defaultContext;<br>}<br><br>Hope that helps,<br>--JW<br><br>----- Original Message ----<br>From: Darren Ellis &lt;darren@ieworks.net&gt;<br>To: Asterisk Users Mailing List - Non-Commercial Discussion &lt;asterisk-users@lists.digium.com&gt;<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.&nbsp;&nbsp;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>&nbsp;&nbsp; <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>