Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
January 30, 2007, 11:36 am
rate this thread
I need to use fsockopen to open a connection, send a GET request and
read in the response. At the moment I'm trying the following code, but
I think it's ignoring the actual URL included in the $request
$host = "www.myhost.com";
$request = "/myurl.php?param1=1¶m2=2¶m3=3";
$fp = fsockopen($host, 80, $errno, $errstr, 3.0);
# Send the get request then, with timeout...
fwrite($fp, "GET / HTTP/1.0\r\n" .
"Content-Length: " . strlen($request) . "\r\n" .
stream_set_timeout($fp, 2, 0);
$response = '';
$response .= fread($fp, 1024);
print $response . "<BR>\n";
What am I doing wrong?