PHP Get Content of HTTP 400 Response

Solution 1:

You have to define custom stream context (3rd argument of function file_get_contents) with ignore_errors option on.

Solution 2:

As a follow-up to DoubleThink's post, here is a working example:

$url = 'http://whatever.com';

//Set stream options
$opts = array(
  'http' => array('ignore_errors' => true)
);

//Create the stream context
$context = stream_context_create($opts);

//Open the file using the defined context
$file = file_get_contents($url, false, $context);