Hi!
I'm using a version of the post to host function. However, instead of just returning one line of data pipe delimited, it is returning a whole page full of garbage, starting with session ID etc.. Any suggestions for why it's not returning the right data?
If I manually go to the URL being passed I get the data string....so not sure what else I should try. Thanks for any help in advance.
lisa
function httpSimulateFormSubmit($host, $method, $path, $data) {
$buf = '';
$fp = fsockopen($host,80,$errno,$errstr,10);
if ($fp) {
if ($method == 'GET')
$path .= '?' . $data;
fputs($fp, "$method $path HTTP/1.0\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp, 1024);
fclose($fp);
return $buf;
}
else{
echo "$errno - $errstr <p>";
return false;
}
}
Here's a sample of the output:
HTTP/1.1 200 OK Set-Cookie: JSESSIONID=A7ABBA7D0F9682C74D74E5DC3BF155FD; Path=/ Content-Type: text/html;charset=ISO-8859-1 Content-Length: 48844 Date: Sun, 11 Apr 2004 01:26:52 GMT Server: Apache Coyote/1.0 Connection: close GIF87avÂÆ1gU(¬ðÜp(ôô\K£¤ð{ä½9Þ%¨÷ÀœÃ¥Àž{"85ˆ)©ØÇ`VáìcZ_RÑ-%Ⴈ‡_æd²8—2s½Cd’“鈔§Í øi$ø˜×Ĉ ¢¦HΫ°