The first thing to do is check the pinout of the encoder by buzzing it out with a multimeter or
continuity tester. You need to start by being certain which pin is which and connect to A, B, gnd....