Whatever possessed you to send the "application/x-www-form-
urlencoded" as mime type?
JSON is nothing like form-encoded. That's like sending your HTML as
"image/jpeg" just for kicks. Don't do that.
JSON's mimetype is "application/json" (see [1] below). If you want to
be nice, you should actually set that in the header (as follows:
Content-type: application/json; encoding=UTF-8 - note that JSON is
defined to be UTF-8 encoded, so you're just clarifying there, you
can't pick your own encoding).
And, yes, of course, in PHP you would have to get the entire request
body, instead of letting PHP try to parse it as form data. Possibly
PHP is presuming that the data IS form encoded when there is no header
at all. Is file_get_contents("php://input"); really the only feasible
way to get the entire body in PHP?
Oh, PHP. Every single time someone posts a code snippet written in
PHP, my aesthetic sense blows its brains out in sheer despair. And
this one is up there, which is really saying something. I think its a
conspiracy by the zend folks to make the inner child of developers
worldwide die a little inside every time they come in contact with it.
Sadistic bastards.