file_get_contents, HTTP request failed

前端 未结 1 1887
时光说笑
时光说笑 2021-01-15 04:02

I try to get content from another site by using file_get_contents but I always get \"failed to open stream: HTTP request failed!\" allow_url_fopen is on, and I

1条回答
  •  隐瞒了意图╮
    2021-01-15 04:49

    Your webserver closes the connection immediately if the client doesn't send a User-Agent header. Try adding a user_agent option to your php.ini, or put:

    ini_set('user_agent', 'PHP');
    

    in your script.

    0 讨论(0)
提交回复
热议问题