false, "title" => "Missing parameters" ]; echo json_encode($response); exit; } $apiKey = $_REQUEST['api_key']; // Get user from API key $sql = "SELECT * FROM user WHERE api_key = :apiKey"; $stmt = $db->prepare($sql); $stmt->bindValue(':apiKey', $apiKey); $result = $stmt->execute(); $user = $result->fetchArray(SQLITE3_ASSOC); // If the user is not found, return an error if (!$user) { $response = [ "success" => false, "title" => "Invalid API key" ]; echo json_encode($response); exit; } // remove password and api_key from array $user['password'] = "********"; $user['api_key'] = "********"; $response = [ "success" => true, "title" => "user", "user" => $user, "notes" => [] ]; echo json_encode($response); $db->close(); } else { $response = [ "success" => false, "title" => "Invalid request method" ]; echo json_encode($response); exit; } ?>