Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP_RAW_POST_DATA empty - alternate solution

Tags:

php

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?

like image 232
Webnet Avatar asked Aug 04 '26 03:08

Webnet


1 Answers

$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

like image 135
Yacoby Avatar answered Aug 05 '26 18:08

Yacoby



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!