请帮我修复我的代码
$fp = fsockopen("projecthoneypot.org/statistics.php", 80, $errno, $errstr, 5);
if ($fp) {
$url = "/";
fputs($fp, "GET $url HTTP/1.1\r\nHost: {projecthoneypot.org/statistics.php}\r\nConnection: close\r\n\r\n");
$resp = '';
while(!feof($fp)) {
$resp .= fgets($fp, 1024);
}
echo "$resp";
}我总是收到这个错误
Warning: fsockopen() [function.fsockopen]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/xxx/public_html/xxx.php on line 3
Warning: fsockopen() [function.fsockopen]: unable to connect to projecthoneypot.org\statistics.php:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known) in /home/xxx/public_html/xxx.php on line 3有什么问题吗?
发布于 2011-11-30 01:25:28
使用fsockopen,您只需要传递ip/主机名。
尝试更改:
$fp = fsockopen("projecthoneypot.org/statistics.php", 80, $errno, $errstr, 5);
// to
$fp = fsockopen("projecthoneypot.org", 80, $errno, $errstr, 5);作为HTTP请求的一部分,Host:应该只是projecthoneypot.org,而不是projecthoneypot.org/stattics.php。
$url可能应该为/statistics.php
https://stackoverflow.com/questions/8314945
复制相似问题