This was said by Imam al-Zuhri (may Allah have mercy on him), and he said: "If he does not know (to face the qiblah), there is no harm in eating it (the slaughtered animal), provided he mentioned the name of Allah over it."
And it has reached us in the hadith of Sayyiduna Jabir bin Abdullah (may Allah be pleased with him) that he said: "The Prophet (peace and blessings be upon him) slaughtered two horned, white-and-black rams on the day of Eid. When he (peace and blessings be upon him) turned them (towards the qiblah), he said: 'I have turned my face, inclining to truth, towards the One who created the heavens and the earth' [Surah al-An'am: 79]." Then he mentioned the (whole) hadith, and it will come (in its place).
And in another narration: "When he (peace and blessings be upon him) slaughtered, he turned both of them towards the qiblah."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الضحايا / Q19173