A
A
Alexander2015-12-28 15:47:55
PHP
Alexander, 2015-12-28 15:47:55

How to get the body of a POST request?

The client generates and sends a POST with the Content-Type: text/xml type, putting data into the xml body.
How to get only the request body? Those. only data. If I read php://input I get everything raw, including headers. It doesn't need me. Is there a variant?
Those. now in php://input

--dd20c743ed8243b8a574885ebe6df7a3
Content-Disposition: form-data; name="data"; filename="Файл обмена 1С-to-Сайт ТИП2.xml"
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?>
<СommercialInformation>
<IDSession>
 2390c14c-2fd7-4658-86be-a4a55d796b98
</IDSession>
<ExchangeType>
 2
</ExchangeType>	
<LastExchangeDate>
 01.01.0001 00:00:00
</LastExchangeDate>
</СommercialInformation>
--dd20c743ed8243b8a574885ebe6df7a3--

I only want to get:
<?xml version="1.0" encoding="UTF-8"?>
<СommercialInformation>
<IDSession>
 2390c14c-2fd7-4658-86be-a4a55d796b98
</IDSession>
<ExchangeType>
 2
</ExchangeType>	
<LastExchangeDate>
 01.01.0001 00:00:00
</LastExchangeDate>
</СommercialInformation>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2015-12-28
@melkij

You mean with headers?
The body of the POST request is exactly php://input
What you sent, you will receive here.

V
Vit, 2015-12-28
@fornit1917

php://input does not and cannot have http headers, only the body.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question