I'm using a PHP script to retrieve a JSON object sent via POST.
The JSON POST request basically looks like this:
POST /script.php HTTP/1.1
Host: xx.xx.xx.xx
Content-Type: application/json
Content-Length: xx
Connection: keep-alive
{var:"value", var2:"value2", etc..}
And the PHP server side code like this:
$content = file_get_contents('php://input');
file_put_contents("check.log", $content);
$data = json_decode($content, true);
I have deliberately wanted to save the received content into a file (check.log) so that I can examine the raw input that is received as it is.
My problem is that when the JSON contains hebrew characters in the places of "value","value2",etc.. they are received as question marks (?????) in the saved file check.log (I have checkd check.log through a hex editor. they are question marks. 0x3F), so the received "check.log" file looks like this:
{var:"?????",var2:"??????",..}
if it helps anyone, I'm using Apache 2.2.3 server with PHP 5.
is this a problem with PHP's internal encoding being set for the php://input wrapper?
is there anyway to fix this?