Having trouble POSTing nested JSON using PHP Having trouble POSTing nested JSON using PHP json json

Having trouble POSTing nested JSON using PHP


From the looks of those var_dumps, I'd say you need to strip those slashes out of $data before you use it. Try stripslashes.


http_build_query also expects an array. Since your data is already a json string, I think you should probably omit it. You may need to url encode it, but you should just use the regular urlencode function for that.

Also, I'm not familiar with the php context mechanism you're using and I'm deeply unsatisfied with the php.net documentation, but I can't shake this nagging feeling that the 'content' => $data is doing something more than just setting the content. Do you have a good documentation link for the stream contexts actually using the 'content' option?