无法打开流:HTTP 请求失败


failed to open stream: HTTP request failed

我的网址有问题在 2-3 小时现在停止工作之前它工作正常当我在另一台服务器上使用它时,它似乎又可以工作了在此停止工作我试过卷曲没有机会失败让我知道还有其他方法可以做到这一点

这是错误

Warning: file_get_contents(http://#.#.#/?id=100) [function.file-get-contents]: failed to open stream: HTTP request failed! in

可能是您需要设置标题,有些网站不允许您在没有标题的情况下查看它们,请尝试以下操作:

$opts = array(
  'http'=>array(
    'method'=>"GET",
    'header'=>"Accept-language: en'r'n" .
              "Cookie: foo=bar'r'n" .
              "User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)'r'n"
  )
);
$context = stream_context_create($opts);
$html = file_get_contents($url, false, $context);

检查他们是否阻止了您的 IP 地址。