Warning: file_get_contents: failed to open stream: Redirection limit reached, aborting

前端 未结 4 1542
北海茫月
北海茫月 2020-12-03 22:40

I read over 20 related questions on this site, searched in Google but no use. I\'m new to PHP and am using PHP Simple HTML DOM Parser to fetch a URL. While this script works

4条回答
  •  青春惊慌失措
    2020-12-03 23:14

    Resolved with:

     array(
                'max_redirects' => 101
            )
        )
    );
    $content = file_get_contents('http://example.org/', false, $context);
    ?>
    

    You can also inform if you have a proxy in the middle:

    $aContext = array('http'=>array('proxy'=>$proxy,'request_fulluri'=>true));
    $cxContext = stream_context_create($aContext);
    

    More details on: https://cweiske.de/tagebuch/php-redirection-limit-reached.htm (thanks @jqpATs2w)

提交回复
热议问题