What is XML-RPC good for? (15 posts)

  1. engtech
    Posted 8 years ago #

    Hiya wordpress.org forumers,

    I was wondering if anyone could clarify a few things for me
    about XML-RPC?

    XML-RPC is used by blogging client software to automatically post to blogs.

    My understanding is that XML-RPC is a container protocol for sending requests from a client application to the WordPress server. Inside of XML-RPC are calls made using the Blogger/Metaweblogs/MoveableType APIs.

    All of the examples I've seen of using XML-RPC seem to be focused around posts and categories. So far I've seen nothing to indicate it can be used for more advanced things than posting to a blog. Is this true?

    I saw something somewhere that made it seem like I might be able to execute any PHP code through the XML-RPC interface? (this would be excellent)

    Long story short, I'm trying to find out if I can use XML-RPC to get meta-information from all the comments on my blog, and then automatically shut down comments on blog posts that are older than a certain date and don't have any comments.

    Using a plugin isn't an option because I'm using WordPress Multiuser.

    Thanks in advanced, I hope this post gets more than just crickets chirping. :)

  2. engtech
    Posted 8 years ago #

    WordPress 2.2 release notes

    "A new set of WordPress-specific XML-RPC APIs that allow for editing pages, setting categories, and much more."

    Are these APIs documented anywhere?

  3. Chris_K
    Posted 8 years ago #

    Couple links, in case you haven't found 'em yet :-)


    which leads to

  4. engtech
    Posted 8 years ago #

    Just found the latest documentation of MT XML-RPC.

    All existing links to it were broken because Six Apart did a reorg.


  5. engtech
    Posted 8 years ago #

    One weird thing... I can't get a list of all post ids via XML-RPC? I would have thought that would be a common command.

    It doesn't look like there's much functionality in XML-RPC when it comes to comments. There is the mt_allow_comments field on posts that I should be able to turn on/off via XML-RPC, but there is no way to find out information about the number of comments on posts.

    I think what I'll do is use the WXR export file as an input, parse it for comment information, and then use XML-RPC to twittle the comments allowed bit automatically.


    This is what I get running mt.supportedMethods

    $VAR1 = [

    and here are some samples of the info I can retrieve about a post

                'permaLink' => 'http://wptheme.wordpress.com/2006/09/11/this-is-a-te st-blog-2/',
                'wp_password' => '',
                'userid' => '190902',
                'mt_allow_pings' => '0',
                'mt_excerpt' => 'POST EXCERPT DISPLAYS INSTEAD OF POST',
                'wp_author_display_name' => 'engtech',
                'dateCreated' => '20060911T00:52:20',
                'link' => 'http://wptheme.wordpress.com/2006/09/11/this-is-a-test-bl og-2/',
                'wp_slug' => 'this-is-a-test-blog-2',
                'mt_allow_comments' => '0',
                'categories' => [
                                'This is a really really really long category name',
                                'Child C',
                                'Category w/ Description'
                'description' => 'Hi there, welcome to <a href="http://engtech.wordp ress.com">//engtech</a>\'s little corner of the Internet for testing out themes on WordPress.com before switching them to my blog.
    <a href="http://wptheme.wordpress.com/2006/09/11/html-tag-test/">Jump directly t o the HTML test.</a>
    Comments are off for this posts, but it does have comments and should display th em.
    This post has an excerpt.',
                'postid' => '4',
                'wp_author_id' => '190902',
                'title' => 'Comments off, excerpt test.',
                'mt_text_more' => ''
                'permaLink' => 'http://wptheme.wordpress.com/2005/09/11/old-post-3/' ,
                'wp_password' => '',
                'userid' => '190902',
                'mt_allow_pings' => '0',
                'mt_excerpt' => '',
                'wp_author_display_name' => 'engtech',
                'dateCreated' => '20050911T03:46:43',
                'link' => 'http://wptheme.wordpress.com/2005/09/11/old-post-3/',
                'wp_slug' => 'old-post-3',
                'mt_allow_comments' => '0',
                'categories' => [
                'description' => 'Creating post archive',
                'postid' => '10',
                'wp_author_id' => '190902',
                'title' => 'Old Post #3',
                'mt_text_more' => ''
  6. engtech
    Posted 8 years ago #

    There's some documentation of what all of the non-WP specific API calls do here:


  7. engtech
    Posted 8 years ago #

    Weird. Whenever I try to use metaWeblog.editPost and just set the mt_allow_comments field I get an error.

    my $call = $self->{ server }->call(
            $self->{ username },
            $self->{ password },
               mt_allow_comments => 1
            1 # 1 - publish
    set_mt_allow_comments: Sorry, your entry could not
     be edited. Something wrong happened.
    at comment.pl line 37
  8. engtech
    Posted 8 years ago #

    I'm hitting a bug and it won't let me use a metaweblogs.editPost call.

    Looking at the xmlrpc.php source code:

    It's dying with the oh-so-helpful "Something wrong happened" error.

    1241 $result = wp_update_post($newpost);
    1242 if (!$result) {
    1243 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.'));
    1244 }

  9. engtech
    Posted 8 years ago #

    I've tried a couple of different pre-wrapped APIs for using MetaWeblogs or MovableType RPC. It seems broken if all you're trying to do is flip the comment bit.

  10. engtech
    Posted 8 years ago #

    If you are using the metaWeblog.editPost method it won't edit the post unless the description field is set. This prevents a lot of cool tricks like writing scripts to do things like turn off comments on all posts older than 30 days.

    What SHOULD happen is if the description isn't set by the metaWeblog.editPost arguments then it will just use the existing description. editPost can be used for a lot more than just editing posts -- it can be used for tweaking any of the settings on a blog.

  11. engtech
    Posted 8 years ago #

    WOW. If you try to take the getRecentPosts response and pass it unmodified into metaWeblog.editPosts it gets REALLY screwed up because of time zones. Which breaks your URLs.

    < <link>http://wptheme.wordpress.com/2005/09/11/old-post-2/</link>
    > <link>http://wptheme.wordpress.com/2005/09/10/old-post-2/</link>
    < <wp:post_date>2005-09-11 03:46:21</wp:post_date>
    > <wp:post_date>2005-09-10 23:46:21</wp:post_date>
    < <link>http://wptheme.wordpress.com/2005/09/11/old-post-3/</link>
    > <link>http://wptheme.wordpress.com/2005/09/10/old-post-3/</link>
    < <wp:post_date>2005-09-11 03:46:43</wp:post_date>
    > <wp:post_date>2005-09-10 23:46:43</wp:post_date>

  12. engtech
    Posted 8 years ago #

    solution is not to pass the dateCreated field.

    base64 characters can cause problems as well, but that is more of an issue with XMLRPC::Lite in Perl.

  13. uberdose
    Posted 8 years ago #

    Hi engtech, thanks for these posts and links! I've had the feeling that XML RPC with wordpress is under-documented for some time now. Will give it a try again ...

  14. engtech
    Posted 8 years ago #

    I'm still having huge headaches with base64 characters killing XMLRPC::Lite in perl. I've tried out XMLRPC::PurePerl and XML::RPC instead, but both of those packages have even more issues than XMLRPC::Lite.

    I found one hack on the net for XMLRPC::Lite that "kinda" got it to work, but it ended up corrupting a lot of the Base64 characters on my blog into something weird.

  15. ladynada
    Posted 8 years ago #

    so passing datecreated is off limits.... any fix for this yet?

    I need help passing categories on the mw_newPost


Topic Closed

This topic has been closed to new replies.

About this Topic