praetorian123
stolyar
intuition...

thanks !
that was very helpful

Intuition is not a good guide when dealing with ENGLISH, especially since "spoken" english has much looser rules than formal written English (which the GMAT is testing):
Formally, the first pronoun should be "he" because it is the subject of the sentence. Hence, use the subjective form "he", not "him." ("No one but" is simply an adjective phrase equivalent to "only").
The second pronoun is linked to the subject of the clause "the king" via the linking verb "was" and refers back to it. This is formally known as a "predicate nomitive". Since the pronoun is directly linked to the subject of the linking verbs, it too uses the subjective form. Examples: It is I. It is she that should be the nominee, not I. It was she who surprised the teacher. Note: since the verb simply links the subject and the pronoun (or two pronouns), they can often be exchanged.
Try rewriting the sentence and you will see it more clearly:
"Only he could have told them that I was the king."