Wordpress API Primer (II - XMLRPC)
March 18th, 2007 | MiscellaneousThe foundation of Wordpress API is built on XMLRPC, and hence if you want to know how the API works then you need to know XMLRPC.
XMLRPC Specification
The authoritative source about XMLRPC is its spec, which includes the following information:
- Sample request & response
- Method name
- XML representation of scalar data (boolean, integer, double, date, string, and base64)
- XML representation of complex data (array and struct)
- Failure response
You might find the spec itself is a bit sparse (which is a prevalent feature in the whole xmlrpc.com), and might want to have some tutorials and samples to go along with the information. Furthermore, who wants to manually construct XML these days?? We want a library to do the work!
PHP Implementations of XMLRPC
It turns out that many people have answered the call - I found that at least 5 major branches of XMLRPC libraries in PHP (there are probably more, but I can’t boil the ocean ;P):
- PHP itself has included an experimental xmlrpc functionality, which can be turned on/off
- The PHP experimental xmlrpc functionality is based on eOpinion’s library
- PEAR also has a library for XMLPRC called PEAR::XML_RPC
- PEAR’s library is based on Edi Dumbill (Useful Inc)’s XML-RPC package
- Lastly but not least, Incutio has a very easy to use XML-RPC package (this is the package used by WP)
How should one go about choosing the right package to use? Below is my quick checklist for decision points:
- Is the library stable?
- Will the library be supported?
- Will the library be available?
- Will the library require additional effort to get setup (e.g. require compilation process)?
And how the libraries stack up:
| Library | Stability | Support | Available | Effort | Conclusion |
| PHP Extension | Experimental, although based on a stable codebase | Not actively supported by PHP due to experimental status | It is included with all PHP distribution, but not compiled or enabled by default | It can be cumbersome to setup | Probably not the best library to use and depend on | XMLRPC-EPI | Appears to be stable codebase, since 1998 | Last update since 2002, so not sure whether it’s actively supported | Not included by default | Requires C compiler, which can be cumbersome | Unless speed is absolutely critical, it might not make sense to use this library |
| PEAR::XML_RPC | Appears to be stable codebase | Appears to be actively supported, since it is in PEAR | Requires PEAR and not included by default | Requires users to setup PEAR and depends on PEAR | While PEAR is awesome, it just introduces additional dependency |
| XML-RPC | Appears to be stable codebase | Appears to be actively supported, latest release in 2007 | Can easily be included in your code | No additional effort to setup | A good choice for distribution | Incutio XML-RPC | Appears to be a stable codebase | The activity on the package appears to be sparse sync 2005 | Can easily be included in your code | No additional effort to setup | IMHO - the easiest package that I’ve found |
Conclusion
While the pure library XML-RPC package such as Useful Inc’s or Incutio’s do not necessarily offer speed, IMHO they are easier to include for distribution, better documentation, and possibly active support.
When comparing the two package, what I found is that:
- Useful Inc’s has more active development and better documentations
- But Incutio’s is easier to use, and is used in WP
What really sold me with Incutio’s package is that by default it assumes that you shouldn’t have to even think in XML at all - it helps you handle as much of conversion from XML to PHP objects as possible, where Useful Inc’s version still requires you to explicitly control the conversion (it does have helper functions that will simplify the process). Incutio’s abstraction will help speed up the development of a WP XMLRPC client.
We will talk about the various API for WP next.

Digg This!
Reddit!
Del.icio.us!
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment