Anyons in one-dimensional lattices: a photonic realization