I need to interface with a REST webserver. When I issue a request, it responds (correctly) with HTTP response code 201 (Created), and the relevant information (JSON object) in the body.
I can verify it using cURL.
I'm trying to get the body it via PHP's file_get_contents
function, specifying a correct context object, with the following code:
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
'header' => $header,
'timeout' => 10.0,
'content' => $body,
'ignore_errors' => true
)
)
);
$answer = file_get_contents($url, false, $context);
However the function always returns a false value and I cannot get the returned body.
What can I do? (I'd rather not call cURL from PHP)