Hey Guys,
I am trying to use some code found online to generate a simulated form submit using post. I was wondering if anyone could help me to understand how to get past this error:
buf = HTTP/1.0 400 Bad Request Content-Type: text/plain Content-Length: 90 Status Code: 400 Bad Request Explanation: Don't know how to process message: MAP_ACTION
Here's the basic function:
function httpSimulateFormSubmit($host, $method, $path, $hdrs, $data) {
// Data = MAP_ACTION=PAN|E&MAP_SIZE=&ZOOM_LEVEL=&FEATURE0=1|location|2|40,-75|3100&CENTER_POINT=&BESTFIT=false&DATA_ONLY=true
$cmd = 'ping -n 1 -w 500 ' . $host;
exec($cmd,$x);
$x2 = implode('',$x);
if (stristr($x2,'Request timed out')==false) {
$fp = @fsockopen($host, 9810);
if ($fp) {
if ($method == 'GET') $path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.0\r\n");
fputs($fp, "Host: $host\r\n");
if (strlen($hdrs)>0) fputs($fp, "$hdrs\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') fputs($fp, $data);
$buf = '';
while (!feof($fp)) $buf .= fgets($fp, 1024);
fclose($fp);
echo "buf = $buf";
return $buf;
}
else return false;
}
else return false;
}
the entire path is:
somewhere.com/path/process.jsp?MAP_ACTION=PAN|E&MAP_SIZE=&ZOOM_LEVEL=&FEATURE0=1|location|2|40,-75|3100&CENTER_POINT=&BESTFIT=false&DATA_ONLY=true
Any ideas on why it bails after the ?
Thanks!!
lisa