I'm using a firefox pluing called restclient to simulate a post request. It doesnt' seem to be picking up any post data, but not sure if I'm formatting it properly.
using header: Content-Type: application/json and body: {"id":1234}
but not go, it's not picking up the id parameter in my php, is there some special formatting I need to set?
okay, got it working, here is what is needed
two content types:
Content-Type: application/json
Content-Type: application/x-www-form-urlencoded
and then set your params like so in body:
param1=value1¶m2=value2
Thanks for the help everyone.
PHP will not parse a JSON body automatically into the $_POST
superglobal. That only happens with application/x-www-form-urlencoded
and multipart/form-data
POST bodies. That said, you can parse the body yourself — you can access the raw POST body via the php://input
pseudo-stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With