"Method not accepted.")); exit(); } $database = new Database(); $db = $database->getConnection(); $auth = new Authenticator($db); $userId = $auth->authenticate(); // get posted data $data = json_decode(file_get_contents("php://input")); $p = new Presence($db); $p->userId = $userId; $p->willBePresent = $data->willBePresent; $p->notes = $data->notes; if($p->create()){ // set response code - 201 created http_response_code(201); echo json_encode($p); } else { // unable to create http_response_code(500); echo json_encode(array("error" => "Unable to create Presence.")); } ?>