[wp-xmlrpc] XML-RPC in Wordpress 3.0

Eric Mann eric at eamann.com
Tue Aug 31 15:22:46 UTC 2010


There isn't a single resource for API documentation because XML-RPC supports
multiple APIs.  Here are a few references for you:
 
- WordPress API: http://codex.wordpress.org/XML-RPC_wp
- Blogger API: http://www.blogger.com/developers/api/1_docs/
- MetaWeblog API: http://www.xmlrpc.com/metaWeblogApi
- Movable Type API: http://www.sixapart.com/developers/xmlrpc/movable_type_api/
 
It is possible to add custom RPC methods through plug-ins.  It's fairly easy to
do, and you can extend custom plug-in functionality this way (you can use
WordPress as any kind of SOAP or REST service if you have the right kind of
extensibility built-in).
 
To add your own function, you'll need to do the following:
 
function xml_add_method( $methods ) {
$methods['myNamespace.myMethod'] = 'my_method_name';
return $methods;
}
add_filter( 'xmlrpc_methods', 'xml_add_method');
 
The above code will add a new XML-RPC method to core.  Any external service can
now post a request to http://blogname.url/xmlrpc.php and call
'myNamespace.myMethod'.  Any arguments passed to that method call will be passed
directly into a PHP function called 'my_method_name'.  So you'll also need the
following:
 
function my_method_name( $args ) {
global $wpdb; // If you want to use this object to load, store, or manipulate
data
 
$args = wp_parse_args( $args );
extract( $args, EXTR_SKIP );
 
...
}
 
Once your arguments are extracted and stored in variables, you can do whatever
you want with them.  If you want an example of how I'm using this for plug-in
callbacks, I suggest looking through the code to my Elliot Server project on
Google Code: http://code.google.com/p/elliot-server/.  This system adds an entry
point that remote plug-ins can post error messages to so a developer can follow
up.  It's a work in progress, though, so expect it to gradually change over
time.
 
~Eric
 

On August 31, 2010 at 2:42 PM nico <nsebban at gmail.com> wrote:


> Hello,
> 
> I've been playing with the XMLRPC API, and I have a few unanswered questions :
> 
> --Is there a Codex page that lists every RPC method, with links to the
> corresponding help page ?
> I couldn't find any...I usually end up catenating the URL
> http://codex.wordpress.org/XML-RPC/with the method name (ie.
> http://codex.wordpress.org/XML-RPC/wp.getComments), and it sometimes works.
> I'll gladly create a codex account and set this page up, if it doesn't exist
> already...I just wanted to be sure it's not redundant.
> 
> --Are there plans for new RPC methods in the near future ?
> I realized that many of the WP3 new features (custom taxonomies, custom post
> types) don't have corresponding RPC methods...are there plans to add these ?
> Is the XMLRPC part of Wordpress still alive ?
> 
> --Is it possible adding custom RPC methods through plugins code ? Do you
> recommend it ?
> I noticed the "xmlrpc_methods" filter, that can be used to add custom RPC
> methods programmatically in plugins. I think I read at some point that the
> whole Wordpress "engine" is not started when dealing with XMLRPC requests...In
> that context, would registering new methods through the filter and loading the
> corresponding callbacks work ? And would you do it that way ?
> 
> Thank you for your answers.
> 
> Nicolas
> 
> 
>


More information about the wp-xmlrpc mailing list