Here is the easiest generalization of the fact you cite about Eilenberg-MacLane spaces. Spaces $X$ with exactly two nontrivial homotopy groups $\pi_n(X), \pi_m(X), 2 \le n < m$ are classified (up to (weak) homotopy equivalence) by these two homotopy groups together with one additional Postnikov invariant, which is a cohomology class in $H^{m+1}(B^n \pi_n(X), \pi_m(X))$, where $B^n A$ denotes the $n$-fold delooping $K(A, n)$ of a discrete abelian group $A$. This class classifies the fibration
$$B^m \pi_m(X) \to X \to B^n \pi_n(X).$$
If $n = 1$ then we need the additional data of the action of $\pi_1(X)$ on $\pi_m(X)$, and then the cohomology above is group cohomology with nontrivial / local coefficients.
Example. The $3$-truncation of $S^2$ has two nontrivial homotopy groups $\pi_2(X) \cong \pi_3(X) \cong \mathbb{Z}$, and all other homotopy groups vanish. The Postnikov invariant is a class in $H^4(B^2 \mathbb{Z}, \mathbb{Z}) \cong H^4(\mathbb{CP}^{\infty}, \mathbb{Z}) \cong \mathbb{Z}$, and I believe it turns out to be a generator.
The natural generalization of this fact is the theory of Postnikov towers, although there the relevant Postnikov invariants are defined in terms of spaces defined in terms of other Postnikov invariants, so it's trickier to tell whether the're different or the same.