Plugin to allow visitor contributions to WordPress posts, wiki style.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
535 B

$requestBody = file_get_contents('php://input');
$requestJson = json_decode($requestBody, true);
if (empty($requestJson['index'])) {
throw new \Exception('index is required.');
$jsonFile = __DIR__.'/tablediffs.json';
$demoStorage = json_decode(file_get_contents($jsonFile), true);
if (!array_key_exists($requestJson['index'], $demoStorage)) {
throw new \Exception('index not found.');
$targetDemo = $demoStorage[$requestJson['index']];
header('Content-Type: application/json');
echo json_encode($targetDemo);