需要带有file_get_contents(PHP)的HTTP 500的响应体

frE*_*EEk 25 php file-get-contents http-error

使用file_get_contents作为自定义SOAP实现的一部分来应用SOAP调用(我们尝试的所有库都不会正确地使用SOAP 1.2进行基于SSL +证书的身份验证).然而,困难且几乎没有文档记录的API通常返回500.响应正文中有错误详细信息,但file_get_contents似乎不允许访问它.fopen似乎也有同样的问题.

做什么?

由于大量使用流上下文来使身份验证正常工作,因此不希望转到cURL.

dtb*_*rne 54

你可能会考虑nusoap.

但是对于你的问题,如果你使用它会有效ignore_errors.

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

$contents = file_get_contents($url, false, $context);
Run Code Online (Sandbox Code Playgroud)

  • [`ignore_errors`](http://www.php.net/manual/en/context.http.php#context.http.ignore-errors) 是这里的解决方案。 (2认同)
  • 砰。正是我需要的。 (2认同)