How to use Php to get extentions status from Asterisk

I would like to develop a php page to show all of the current status of extentions in Asterisk, I guess there should be a API in Asterisk, but I didnot find it.

Anybody knows how to do it? Thanks in advance is the place to look for these things.