Here's the answer:
“j'ai écrit un livre il y a deux ans”
Watch a real native speaker say it:
Here's how it sounds in a textbook:
Fun fact: the hundreds of thousands of people learning French with Memrise get this phrase correct 97.09% of the time!