
If you’ve been following along you should now be able to perform a test XML-RPC call against your target WordPress installation. Next, although optional, it’s a good practice to add an XML-RPC specific user, with a Role of “Contributor”: To enable it: go to Settings > Writing > Remote Publishing, and check the box next to XML-RPC: XML-RPC is disabled in WordPress by default. This means that you can write a client without worrying about composing and decoding the XML transport strings, you can pass plain old PHP datatypes to the remote procedure, and receive plain old PHP datatypes in response. XML-RPC is well supported by PHP, which provides the “experimental” xmlrpc_encode_request() and xmlrpc_decode() methods which will generate the request XML, and parse the response XML into PHP datatypes, respectively. All the standard datatypes can be represented, including boolean, integer, double and struct (associative-array), among others. This example demonstrates an array containing string values. Lets take a look at a sample request/response:Īs shown by the above examples, constructing an XML-RPC request is quite simple, and the protocol defines a number of standard datatypes which can be returned. An XML-RPC client can be written in virtually any programming language, making it a very flexible choice for an API implementation. It’s an ideal way to programmatically interact with WordPress as XML-RPC is supported in the WordPress core.

XML-RPC provides a means of remotely calling methods on a target system, and is simpler to understand and implement in general than SOAP. XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism. I assume a relative unfamiliarity with XML-RPC in general, WordPress XML-RPC, and spend time first covering the basics, if you want to skip straight to the section on extending the WordPress XML-RPC API, feel free to.
#Xml rpc client example how to#
The purpose of this article is to describe the WordPress XML-RPC API, explain how to use it, and demonstrate how to extend it to create custom API methods for interacting programmatically with WordPress.
