OMG, my dad told me this story when I was little. (My dad is a huge Chinese history buff, I probably have countless of these stories floating around in my subconscious.)
And it wasn’t quite as simple as having the gates open. (If that was all it took, it wouldn’t be a very good story.) The somewhat more elaborate version is that the attacking general had a very good ear for music and when he heard the lute playing, it sounded tremendously steady and confident, which convinced him that it was a trap. The bluff was furthered enhanced by people sweeping at the gate to make it seem like the city was more populated than it was.