ODK Aggregate JSON Server in PHP

Just recently joined the forum and after reading the documentation on JSON Publisher I've manage to come up with a simple REST API in PHP.

Screenshot from my ODK Aggregate Server

ODK Aggregate JSON Publish Data

json.php source code:


header("Content-Type: application/json; charset=UTF-8");

$file = "submission.json";
$json = json_decode(file_get_contents("php://input"), true);

if ($json['token'] == "secret") {
    $data = $json['data'];
    $submission = print_r($data, true);
    file_put_contents($file, $submission . "\n", FILE_APPEND | LOCK_EX);
} else {


I hope this can help others to setup their own JSON Server.

1 Like