Processing math: 100%
Live2D

file_get_contents HTTP request failed! Internal Server Error

使用file_get_contents报错

Severity: Warning
Message: file_get_contents(http://geetest.com:8000/select?gid=bf59a3fe652ece81dfb179219ce5b46e&date=2013-08-09) [function.file-get-contents]: failed to open stream: HTTP request failed! Internal Server Error

遇到这种情况不要慌,我们只要将php默认的user_agent改成Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)进来模拟浏览器即可。

修改方法:

PHP伪造user_agent

   ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');

伪造自后还是不行

  $context = stream_context_create(array('http'=>array('ignore_errors'=>true)));

  nos=filegetcontents(url, FALSE, $context);

 

 

完整栗子:

ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; GreenBrowser)');
context=streamcontextcreate(array(http=>array(ignoreerrors=>true)));filegetcontents(url, FALSE, $context);

 

 

posted @   韦森  阅读(530)  评论(0编辑  收藏  举报

喜欢请打赏

扫描二维码打赏

微信打赏

点击右上角即可分享
微信分享提示