Observation of an effective magnetic field for light