If you have trouble figuring out whether something is a direct or indirect object, consider these rules:

a) A person or thing not preceded by a preposition is a direct object.
   J’ai acheté le livre. > Je l’ai acheté.
   I bought the book. > I bought it.

b) A person preceded by the preposition à or pour* is an indirect object
   J’ai acheté un livre pour Paul – Je lui ai acheté un livre.
   I bought a book for Paul – I bought him a book.
*Pour only in the sense of a recipient (Je l’ai acheté pour toi > Je te l’ai acheté), not when it means « on behalf of » (Il parle pour nous).

c) A person preceded by any other preposition cannot be replaced by an object pronoun
   J’ai acheté le livre de Paul. > Je l’ai acheté (but « de Paul » is lost)
   I bought Paul’s book. > I bought it.

d) A thing preceded by any preposition can’t be replaced by an object pronoun in French:
   Je l’ai acheté pour mon bureau. > « Bureau » cannot be replaced by an object pronoun
   I bought it for my office.

Note: The above rules refer to the use of prepositions in French. Some French verbs take a preposition even though their English equivalents do not, while some French verbs don’t need a preposition even though the English verbs do. In addition, sometimes the preposition is only implied. When trying to determine whether something is a direct or an indirect object in French, you have to consider whether there is a preposition in French, because what is a direct object in French can be an indirect object in English and vice versa. See verbs with and without prepositions.

More examples:

J’ai dit la vérité à toi et Marie > Je vous ai dit la vérité. – I told you and Marie the truth > I told you (both) the truth.

When the indirect objects toi et Marie are replaced by vous, there is no preposition visible. However, if you look up the verb dire in the dictionary, it will say something like « to tell someone something » = dire quelque chose à quelqu’un. Thus the French preposition is implied and the person you are telling (« you ») is in fact an indirect object while the thing being told (« the truth ») is the direct object.

J’écoute la radio. > Je l’écoute. – I’m listening to the radio. > I’m listening to it.

Even though there is a preposition in English, the French verb écouter means « to listen to » – it is not followed by a preposition and thus in French « radio » is a direct object while in English it is an indirect object.