Не могу получить JSON отправленный через POST

В скрипте на удалённом серере есть код, который принимает запрос, разбирает его и выполняет.

$json = file_get_contents('php://input');
$arr = json_decode($json, true);
file_put_contents("/home/ssmok.txt", "JSON: $json ".print_r($_REQUEST, true), FILE_APPEND);

Менять его нежелательно, т.к. другие скрипты отправляют на него запросы и модификация этого кода может сломать их.

Я пытаюсь отправить запрос на него так:

$data_string = json_encode(array(
        'action' => 'put_check_file',
        'file_name' => $file_name,
        'file_name_data' => $file_name_data
    ));

$opts = array('http' =>
    array(
        //'header'  => "Content-type: application/x-www-form-urlencoded\r\nProxy-Authorization: Basic $proxy_auth",
        'header'  => "Content-type: application/json\r\nProxy-Authorization: Basic $proxy_auth",
        'method'  => 'POST',
        'proxy' => 'tcp://'.$proxy,
        'content' => $data_string
    )
);

$context = stream_context_create($opts);
$result = json_decode( file_get_contents("http://".$domain."/", false, $context), true);

Но на удалённом сервере, в файле /home/ssmok.txt неизменно получаю пустой массив. Почему?

JSON:  Array
(
)

Ответы (0 шт):