I'm having some trouble getting the raw data from POST. I'm working with a company that sends by post a txt message from mobiles phone. The company documentation says that their system will send a XML with all the information from the txt message: phone number, time, text, etc.
Inorder to get the info, i'm using the php's function file_get_contents("php://input") , that works perfectly... except when the text message contains special characters ( like á or ñ ). I get a broken XML.
If the XML is like
<?xml version="1.0" encoding="utf-8"?>
<TXT>
<number>12345</number><destination>1111</destination><text>helló world!</text><time>2005-08-12</time>
</TXT>
With file_get_contents I get:
<?xml version="1.0" encoding="utf-8"?>
<TXT>
<number>12345</number><destination>1111</destination><text>
I know this, because I write the txt with fwrite on a file. The company told me that If the message has a special character, they change the text form utf-8 to unicode... but the XML keeps coming as encoding="utf-8" .
Then I've tried to open the file with the XML with an editor with encoding unicode, and the result was
<?xml version="1.0" encoding="utf-8"?>
<TXT>
<number>12345</number><destination>1111</destination><text> h e l l ó w o r l d ! e l l ó w o r l d </text><time>2005-08-12</time>
</TXT>
The thing is , when I try to parser the xml to an array, the fields text and time are missing in the array.
I don't know if the problem is mine, cause I'm doing something wrong when I try to get the information. Or is a problem from the company that's sending the XML in a wrong format.
Greetings, Majobsas