php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决

Posted jackylee92

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决相关的知识,希望对你有一定的参考价值。

在使用file_get_contents方法来获取远程文件时会出现

[function.file-get-contents]: failed to open stream: HTTP request failed!

错误

解决方法是:修改php.ini 中的allow_url_fopen = On 这样可以解决部分人的问题,

完美的解决方案还得修改user_agent="PHP"  ,将参数改为Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)

user_agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

模拟浏览器就可以了;

以上是关于php file_get_contents失败[function.file-get-contents]: failed to open stream: HTTP request failed!解决的主要内容,如果未能解决你的问题,请参考以下文章