<?php
echo file_get_contents('php://input');
もうちょっと細かいことやった版
<?php
sleep(1);
$data = json_decode(file_get_contents('php://input'), true);
header('Content-Type: application/json');
echo json_encode($data);
条件で失敗する版
わざと失敗する状況を作りたい場合に。
<?php
sleep(1);
$data = json_decode(file_get_contents('php://input'), true);
if ($data['bad']) {
http_response_code(400);
header('Content-Type: application/json');
echo json_encode($data);
}
else {
header('Content-Type: application/json');
echo json_encode($data);
}