The author, Frank Stockton, really doesn't tell us how she learns the secret, but he does give us a couple of clues. First of all, she is a princess and with that title comes money. She is also used to getting what she wants, and it would not be hard for her to bribe a lowly door keeper with money (Stockton says she uses "gold" to discover the secret). Stockton also says that she uses her "woman's will" to gain the secret. This can be read many different ways--she was either very assertive and demanding or she was good at flirting with the door keeper. She is a barbaric princess, so a little arm twisting isn't out of the realm of possibility. She could also use her feminine charms to make the door keeper submit to her wishes. However she found out the secret of the doors, the real secret is which door she signals her lover to choose.