Hi all. I'm trying to do a http POST request from within my php script and trying to read the reply with the following code:
$socket = fsockopen($host, 80, $errno, $errstr);
if (!$socket) {
$result["errno"] = $errno;
$result["errstr"] = $errstr;
return $result;
}
fputs($socket, $reqheader);
while (!feof($socket)) {
$result[] = fgets($socket, 4096);
}
fclose($socket);
echo $result;
Unfortunately the code just goes into an infinite loop and times out. If I don't use a while loop and simply put $result[] = fgets($socket, 4096); I find that the array is empty.
Can anyone help me rectify this problem? I need to get the POST replies from the server. Thanks.