How to get a bitcoin address's balance? I know blockchain.info has an API: https://blockchain.info/q/addressbalance/134dV6U7gQ6wCFbfHUz2CMh6Dth72oGpgH
gets the bitcoin address's balance,but it's not open source and must connect to the Internet.

And I find the open source website blockexplorer.com has not show the right balance:
http://blockexplorer.com/testnet/address/134dV6U7gQ6wCFbfHUz2CMh6Dth72oGpgH
It gets 0 but not 1250000 from blockchain.info.

I tried bitcoin-qt client debug console:
getbalance 134dV6U7gQ6wCFbfHUz2CMh6Dth72oGpgH
But it returns 0 whenever the address is not mine.

How can I get someone else's bitcoin address's balance?
The bitcoin database is big and hard to check every transaction to get the balance.

Is there any source code or API easy to use?
blockexplorer.com does show the right balance. However, you are looking up in the Testnet blockchain.

The right request is the following:
http://blockexplorer.com/address/134dV6U7gQ6wCFbfHUz2CMh6Dth72oGpgH

If you open that link, you will see that it shows the right balance.

As you have mentioned, blockexplorer.com is open source, so you probably want to look at the source code to find out how the mechanism you are interested in works.