Forum Moderators: coopster
(works ok, until i specify a subdirectory. the error message) Warning: fsockopen() [function.fsockopen]: unable to connect to (snip) No such file or directory (2)
$current_url="www.example.com";
$fp = fsockopen ($current_url, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$current_url."\r\n\r\n");
while (!feof($fp)) {
$current_url_content.=fgets ($fp,128);
}
fclose ($fp);
}
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known
I just i also tried "www.example.com/example/index.php" and i get the same message.
I was still trying and already changed a bit of the code, i will post it again sorry.
$current_url="www.example.com";
$current_dir="www.example.com/sub/index.php";
$fp = fsockopen ($current_dir, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "GET / HTTP/1.0\r\nHost: ".$current_url."\r\n\r\n");
while (!feof($fp)) {
$current_url_content.=fgets ($fp,128);
}
fclose ($fp);
}
(of course example.com is not the domain i'm trying to acces, i replaced my url with that)
it should be hostname, not URL not DIR
url should be present in HTTP Protocol request headers
GET /sub/index.php HTTP/1.0
Host: www.example.com
hrm... do u know the differences between hostname/url/directory :P