A court in Thailand has cleared former Prime Minister Thaksin Shinawatra of royal defamation charges that had left him facing possible prison time.