file_get_contents:拒绝连接

时间:2011-10-31 22:50:05

标签: php file-get-contents

我有以下代码在我的计算机上正常运行但在线失败:

<?PHP
    header("Content-Type: text/plain");

    $username = "username";
    $password = "password";
    $url = "http://s6.voscast.com:7158/admin.cgi?mode=viewxml";

    $context = stream_context_create(array(
        'http' => array (
            'method' => "GET",
            'header' => "Authorization: Basic ".base64_encode($username.":".$password)."\r\n".
                        "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.835.202 Chrome/14.0.835.202 Safari/535.1"
        )
    ));

    print file_get_contents($url, false, $context);
?>

这完全适用于当地;我能够获取HTTP-Basic身份验证背后的URL并打印它。

然而,当我将它上传到我的服务器时,它不起作用并吐出来:

<br />
<b>Warning</b>:  file_get_contents(http://s6.voscast.com:7158/admin.cgi?mode=viewxml) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: Connection refused in <b>/home/livshin/public_html/wp-content/uploads/_radio/songinfo.php</b> on line <b>16</b><br />

有没有办法可以在这个或者什么东西上获得堆栈跟踪,这至少可以让我更好地了解出了什么问题?

*我已经测试过以确保file_get_contents("http://google.com/")之类的内容适用于服务器。

1 个答案:

答案 0 :(得分:1)

您的服务器可能不允许端口7158上的传出连接。位于端口80上的Google可以正常工作。您可能需要更改防火墙。

相关问题