You can test the JSON+POST handling with cURL. It makes sense that the JSON isn't handled via normal $_POST since there's really no key, per se essentially you just need the "blob" of data as a whole, which is provided by php://input. some features not found in ext/json, such as encoding native JSON expressions, communicating class inheritance. Both functions only works with UTF-8 encoded string data. ![]() From there you use json_decode to turn the JSON string into a workable object/array. These functions are jsonencode() and jsondecode(), respectively. $json_str = file_get_contents('php://input') įile_get_contents, which I though was only used to retrieve content from local files or traditional URLs, allows you to use the special php://input address to retrieve JSON data as a string. I had expected the data to land in $_POST but the variable was empty how the hell do I get the POST data? To get POST JSON with PHP, you use the following: You are accessing it with array-like syntax: echo jstringdecoded'urls'1 Whereas object is returned. Part of the authentication transaction requires Phabricator to receive a POST request that contains JSON data. Coming back to a language you haven't touched in years feels like a completely new experience you notice patterns and methods that you wouldn't have guessed of in years past. You can either put the data in the data object or change the ajax.dataSrc option to be dataSrc. This task has thrust me back into the world of PHP, a language I haven't touched much (since version ~5.2) outside of creating WordPress themes and plugins for this blog. You have dataSrc: data but the JSON is not in a data object. ![]() My recent work at Mozilla has me creating an OAuth-like authentication transaction between Bugzilla and Phabricator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |