Please note that there is full DMAPI based interface written in PHP available. It is free to download and modify, and could be downloaded from Sourceforge.
Please read more at section Reseller Control Panel.
The published examples in PHP are parts of this project and are stripped in terms of functionality and error handling. It is strongly recommended to use the complete code base from Sourceforge.