Nessa has started off a series looking at writing your own API with part one posted recently focusing on the client-side first, writing an interface for their API.
Though in real applications you wouldnâ€™t need an API, all youâ€™d need is a PHP script that accepts GET or POST input to perform some kind of action. In this example, weâ€™ll have a script that automatically adds DNS zones to a nameserver that runs cPanel as well. Most APIs do the same thing - you have a script, then that script accepts post/get variables, then does something.
Her example creates the request - a server, path, IP and hash key - and sends it off to the remote system. The result is pulled back in and parsed through a SimpleXML object. The credentials allow for access lists and a bit of security on the backend.