Chapter 10. XML-RPC
WordPress is awesome, and you can build a lot of really cool applications just with it, but what if your application needs to communicate with other applications or other WordPress installations?
XML-RPC is a remote procedure call (RPC) protocol that uses XML to encode its calls and HTTP as a transport mechanism. WordPress uses an XML-RPC interface to easily allow developers to access and post data from other applications, including other WordPress sites.
We’ve compiled a list of some of the available methods of the wp_xmlrpc_server class along with the arguments that can be used and what values each function returns.
If you would like to follow along with the code examples for some of the following methods, set up the following function in a custom plugin or in your theme’s functions.php file. Also, be careful because some of the examples update and delete data:
<?phpadd_action('init','wds_include_IXR');functionwds_include_IXR(){// You need to include this file in order to use the IXR class.require_onceABSPATH.'wp-includes/class-IXR.php';global$xmlrpc_url,$xmlrpc_user,$xmlrpc_pass;// Another WordPress site you want to push and pull data from$xmlrpc_url='http://anotherwordpresssite.com/xmlrpc.php';$xmlrpc_user='admin';// Hope you're not using "admin" ;)$xmlrpc_pass='password';// Really hope you're not using "password" ;)}?>
wp.getUsersBlogs
Calls the function wp_getUsersBlogs( $args ) and requires an array:
- $username—A string of the username ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access