Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created October 28, 2017 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronpk/5b116bb2fbc1b21fdf3b551b6c9bf949 to your computer and use it in GitHub Desktop.
Save aaronpk/5b116bb2fbc1b21fdf3b551b6c9bf949 to your computer and use it in GitHub Desktop.
<?php
// Convert form-encoded request to JSON equivalent
if(isset($_POST['h'])) {
$h = $_POST['h'];
unset($_POST['h']);
$input = [
'type' => ['h-'.$h],
'properties' => array_map(function($a){ return is_array($a) ? $a : [$a]; }, $_POST)
];
} else {
$input = json_decode(file_get_contents('php://input'), true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment