Temperatures and Metallicities of M Dwarfs in the APOGEE Survey