Parent, Grandparent, King, and Travel passwords are encoded with the username. Unless you're willing to reset your Tamagotchi then set its username to someone elses username, or happen to find someone who chose the same username that you did, their passwords will not work for you.
You have to donate points to the king before you are allowed to visit him. At certain donation levels, you will be given a password. Have a paper and pencil handy, because they don't stay on the screen for long. The password donation levels are 5000, 12000, and 30000. You have to break your donations down into at least three transactions between each level, so you should make multiple small donations. The king's servants will keep track of how much you've donated so far.
start donating
2000+2000+1000 = 5000 --> get a password
continue donating
+3000+3000+1000 = 12000 --> get a password
continue donating
+4000+4000+5000+5000 = 30000 --> get a password
When you use the 5000-point donation password to visit the king, he will give you a password for the Ring souvenir. When you use the 12000-point donation password to visit the king, he will give you a password for the Cape souvenir. When you use the 30000-point donation password to visit the king, he will give you a password for the Crown souvenir.