php - how to access record variables ($ _POST is empty)

I am working on a system and am currently trying to implement a script that another (external) system may publish for some data so that I can store it.
I have no control over the external system - I can just run it to send data to my system by specifying the script URL in it.

Looking at firebug when a message occurs, I see the published data, something like this: enter image description here

or (urldecoded)

content={"sex":"male","person":{"name":["chris"],"mbox":["mailto: name.lastename@gmail.com "]}} &Content-Type=application/json &auth=DDE233H76BGN 

My problem is that when I try to get these parameters in my script, $ _POST (and $ _REQUEST) is always empty!
I tried var_dump($_POST) or echo file_get_contents("php://input"); but I do not see the content.

What am I missing here?
I don't know if response / request headers are needed to get any of this, I am showing them here just in case
enter image description here

Edit:
My script now consists of one line of code, for example:

 <?php var_dump($_POST); ?> 

or

 <?php echo file_get_contents("php://input"); ?> 

both of them give me absolutely nothing: s

+4
source share
3 answers

Data access should be done using $arr= json_decode($_POST['content']); ... but you have another problem.

Missing item:

... how firebug can show you the contents of $ _POST sent from an external system to your site (otherwise: the request does not go through your browser, but probably through the CURL request coming from the external server). Obviously, I don’t understand anything.

I see a POST request sent from your browser (in javascript) made by your site. Your question will miss an important detail, I'm just not sure what it is.

Hint:

Try putting echo 'test'; just before your var_dump, I got the feeling that you cannot debug a page that is really triggered by the AJAX POST request that we see in Firebug. A little routing problem?

+1
source

Let's take a look at RFC 1945 to see what the “parameter” is

 parameter = attribute "=" value attribute = token token = 1*<any CHAR except CTLs or tspecials> CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)> 

So, I assume that "Content-Type = application / json" is not a valid part of POST, because "-" does not apply to CTL

0
source

You should try looking at the raw POST data variable:

echo $HTTP_RAW_POST_DATA;

0
source

Source: https://habr.com/ru/post/1447815/


All Articles