$_POST
contains the key-value pairs of the data submitted as normal form data. Because you sent JSON data, it doesn't get parsed the same.
You need to retrieve the request body. You can either use http_get_request_body()
or treat the body as a file using fopen('php://input')
. Once you have read the request body, you can use json_decode()
to parse it.
$x = json_decode(http_get_request_body());
See: