Ben
Ben

Reputation: 62444

HTTP_RAW_POST_DATA empty - alternate solution

I'm trying to use a script that is provided by an E-commerce site that obtains data from an XML feed that is posted to a URL on my site. The script gathers the data using....

$requestBodyXML = new DOMDocument();

# Load the request body into XML and check that the result has been parsed into XML
if ($requestBodyXML->loadXML($HTTP_RAW_POST_DATA) == true)

The problem is that there's no data being passed. I understand this is depreciated, but how else would I accomplish this?

Upvotes: 2

Views: 7928

Answers (1)

Yacoby
Yacoby

Reputation: 55465

$HTTP_RAW_POST_DATA requires an ini value to be set, using the input stream should work without any special ini settings and is also the 'prefered' method. It is worth noting that neither php://input or $HTTP_RAW_POST_DATA is available with enctype="multipart/form-data".

//The alternative method
$postData = file_get_contents('php://input')

Documentation

Upvotes: 17

Related Questions