Wordpress XMLRPC API | Remote Control Wordpress

Before anything: Be aware that this is the easiest to use yet most complex Wordpress XMLRPC script you will find out there. Make sure you bookmark this page as you will return here if you're serious about your XMLRPC needs. See also a basic autoblog engine example.

WORPDRESS.MU BLOGS MANAGEMENT SUPPORT WAS ADDED.

Got this comment and several others along the same lines.

Hey 5ub,

The new Theme Plugins Manager System is cool and stuff but you promised, quite a while ago, to republish the paid-version of your WP.XMLRPC class.
Theme Plugins are cool but automated content is a bit more important to me right now and I'm waiting ... and waiting.

I understand you're busy with your other stuff but don't forget about those STILL WAITING!

Thanks.

I Apologize And I Am Aware Of This

OK! I got it and I know I've been dragging this because I didn't have time to properly document it and I won't have time to do it any time soon as I have other ventures that actually bring money :) and those have priority ... no offsense. So I'll have to publish it as it is. The functions are very explicit and I will teach you the basics here. But documentation for each function will have to wait a bit.

Truth is I'm 100% sure those who will get it will know / figure out quickly how to use it. I know the kind of people who use this blog are good at what they do and can quickly understand this class. After a day of testing you'll be experts in Remote XMLRPC Wordpress Publishing.

To overcome the lack of documentation you will receive some bonuses:

  1. My XMLRPC Extender Modular Plugin that provides more functions to XMLRPC and free updates (new modules) as I write them (expect quite a bunch).
  2. Bulk Pluginator - A plugin that will allow you to activate/deactivate plugins on all Wordpress blogs in your database.
    This will be Godsend for those with many blogs in one database who need to enable a new plugin on all of them.

I will reply to all your questions and help you where you get stuck and, as I will add documentation to the XMLRPC Class, I will update it here. This is the best I can offer for now. The class is excellent, easy to use, with explicit functions and parameters, intuitive in terms of parameters types and ... did I meantion it's very easy to use.

See below a bunch of common XMLRPC operations you will be performing on your Wordpress blog and the code required to complete them.

Let's Explain The XMLRPC Extender Modular Plugin

It's a plugin that, once activated, will bring more operations to XMLRPC like:

  1. rSQL = Remote SQL ... do remote queries and get results
  2. Options Manager = Manage all options of the blog
  3. Custom Field Manager = Manage custom fields for blog posts
  4. Plugins Manager = Remote manage plugins: Activate/Deactivate
  5. File Manager = List Files [Recursively]
  6. rFC = Remote Function Call ... call Wordpress function with XMLRPC calls

Use this to get all methods: $wp->doRpcRequestUP('5ub.*'); I'll document these too. Bear with me!

Bulk Pluginator Wordpress Plugin Can Do Magic

This plugin itself is enough to justify buying this. It can look through a database and identity all Wordpress installations. Then it will allow you to select a bunch of those and enable / disable plugins on them. There are two small issues with this plugin:

  1. Plugins directory structure needs to be uniform
  2. And the registered activation hook will not kick in as the install is made directly to the database

This can be a problem if a plugin creates some stuff on activation but, if properly written ... modified ... any plugin will work.

I use this functions in databases where I have 50+ blogs and need new plugins (un)installed on all at once. Like removing an advertising module and adding a new one and so on...

And Now ... The XMLRPC Wordpress API

These are just a bunch of the functions it has but these are the most important you will use.

Instantiating the XMLRPC class

$wp = new elWpAPI('http://.../xmlrpc.php', 'admin', '...');

Listing categories and tags

<?php // Categories have light details and categoriesEx have full details $categories = $wp->getCategories(); $categoriesEx = $wp->getCategoriesEx(); // Tags have light details and tagsEx have full details $tags = $wp->getTags(); $tagsEx = $wp->getTagsEx(); ?>

Listing pages

<?php // Get last 10 pages ... complete details $last10Pages = $wp->getPages(10); // Get all pages ... complete details $allPages = $wp->getAllPages(); // List all pages - 'light' details $listPages = $wp->getPageList(); ?>

Creating Categories

<?php // NewCategories returns an associated array (category => ID) // Make sure first parameter is an array of string $newCategories = $wp->newCategories(array('Category1', 'Category2')); // And this is the advanced way of creating new categories ... one at a time $CatID = $wp->newCategory('Category', 0, 'category-slug', 'Category Description'); ?>

Tags can not be created like categories. They are added directly to new posts.

Post And Comment Statuses

<?php // Possible comment statuses $commentStatuses = $wp->getCommentStatusList(); // Possible post statuses $postStatuses = $wp->getPostStatusList(); ?>

List Authors

<?php // Current user details $author = $wp->getUserInfo(); // Author listing ... 'light' on details $authors = $wp->getAuthors(); // Author listing ... 'advanced' details $authorsEx = $wp->getAuthorsEx(); ?>

Creating A New Post: Light Version

<?php // Create a new 'simple' post $postID = $wp->newPost('Simple Post Title', 'Simple Post Text', array('Category1', 'Category2')); // And get the Post basic informations $post = (array)$wp->getPost($postID); ?>

Creating A New Post: Complete Version

<?php // Let's create a Post ... the advanced way $newPost = new elWpNewPost('post'); $newPost->set( 'Advanced Title', // Post title 'Advanced Text', // Post text 'Advanced More', // Optional more text 'Advanced Excerpt' // Optional excerpt ); // Posts with a future date change status to future by themselves $newPost->set_status('publish'); // Set post slug: nice permalink thingy $newPost->set_slug('post-slug'); // Create categories before assigning them $wp->newCategories(array('Category3', 'Category4')); // Add categories next $newPost->add_categories('Category3', 'Category4'); // Add post tags $newPost->add_keywords('tag1', 'tag2'); // Add custom fields $newPost->add_custom_field('cf', 'value1'); $newPost->add_custom_field('cf', 'value2'); $newPost->add_custom_field('cf1', 'value11'); $newPost->add_custom_field('cf2', 'value22'); // Enable both comments and pings $newPost->enable(true, true); // Scheduled 1 Day from now ;) ... use 0 for current time $newPost->set_time(time() + (24 * 3600)); // Create the Post and get the ID $postIDEx = $wp->newPostEx($newPost->as_array()); // And get the Post complete informations $postEx = (array)$wp->getPostEx($postIDEx); ?>

Deleting A Post

$result = $wp->mw_dropPost($postID);

Creating New Pages

<?php // Create A Page ... the 'light' way $pageID = $wp->newPage('title', 'text', 'more', 'slug', true); // Let's create a Page ... the advanced way $newPage = new elWpNewPage(); $newPage->set( 'Advanced Title', // Post title 'Advanced Text', // Post text 'Advanced More', // Optional more text 'Advanced Excerpt' // Optional excerpt ); $newPage->set_status('publish'); $newPage->set_slug('advanced-slug'); // Add custom fields $newPage->add_custom_field('cf', 'value1'); $newPage->add_custom_field('cf', 'value2'); $newPage->add_custom_field('cf1', 'value11'); $newPage->add_custom_field('cf2', 'value22'); $newPage->wp_author_id = 2; $newPage->set_parent(0); // Create the Page and get the ID $pageIDEx = $wp->newPageEx($newPage->as_array()); // And get the Post complete informations $pageEx = (array)$wp->getPostEx($pageIDEx); ?>

Creating A New Comment, Editing It And Removing It

<?php // Must create a user comment first $commentID = $wp->newUserComment($postID, 'Comment - '.md5(time())); // Then edit it to change name, URL and so on $success = $wp->editComment( $commentID, // Edit commentID 'Comment Changed - '.md5(time()), // New comment text 'Author', // Author name 'http://www.somedomain.com/', // Author URL 'author@wp.mu', // Author EMail 'approve', // Comment status time() // Timestamp ); // Drop the just added comment $wp->dropComment($commentID); ?>

Issuing A Custom XMLRPC Command

<?php // This adds username and password as first two params $wp->doRpcRequestUP('method', 'param1', 'param2'); // This needs params as an array $wp->doRpcRequestArgsUP('method', array('param1', 'param2')); // Do a raw request ... params are not changed in any way $wp->doRpcRequest('method', array('param1', 'param2')); ?>

Assigning A Template To A Page

Repeat after me. Get and Update. There is no such thing as direct set. Get page details and Update them. Or use optional 5ub.RPC plugin with the 5ub.rFC module.

<?php // Get the page information as an array $page = $wp->getPage($pageID); // Assign a new template ... by filename not by template name $page->wp_page_template = basename($template_file); // Update page information $wp->setPage($pageID, $page); /* -- Or use rFC ... remote Function Call --*/ $success = $wp->doRpcRequestUP( '5ub.rFC', 'update_post_meta', $pageID, '_wp_page_template', basename($template_file) ); ?>

Changing Permalink Structure

This can only be achieved by using  5ub.Options in the included 5ub.RPC plugin.

<?php // Changing permalink structure using elWAPI + 5ub.RPC // http://codex.wordpress.org/Using_Permalinks // -- // Get permalink structure ... this may be skipped $permalink = $wp->doRpcRequestUP('5ub.optionsGet', 'permalink_structure'); $permalink = '/%year%/%monthnum%/%postname%/'; // Set this to whatever // Update permalink structure $wp->doRpcRequestUP('5ub.optionsSet', array('permalink_structure' => $permalink)); // Get permalink structure again to validate ... this may be skipped $permalink = $wp->doRpcRequestUP('5ub.optionsGet', 'permalink_structure'); ?>

Change Default Comment Status

This can only be achieved by using  5ub.Options and 5ub.rSQL in the included 5ub.RPC plugin.

<?php // Get the tables before anything else $tables = $wp->doRpcRequestUP('5ub.rSQL', "get_tables"); // Changing default comment status $default_comment_status = 'close'; // close or open $wp->doRpcRequestUP('5ub.optionsSet', array('default_comment_status' => $default_comment_status)); $default_comment_status = $wp->doRpcRequestUP('5ub.optionsGet', 'default_comment_status'); // Turn off comments on all existing posts $wp->doRpcRequestUP('5ub.rSQL', 'query', "UPDATE {$tables['posts']} SET `comment_status`='close'"); ?>

Add www. to site root URL

This can only be achieved by using  5ub.Options in the included 5ub.RPC plugin.

<?php // Add www to non-www hostnames for site root // Use with caution, don't append to subdomains $siteurl = $wp->doRpcRequestUP('5ub.optionsGet', 'siteurl'); if(!preg_match('~^https?://www\.~i', $siteurl)){ // If not www found ... add it $siteurl = preg_replace('~^(https?)://~', '$1://www.', $siteurl); $wp->doRpcRequestUP('5ub.optionsSet', array('siteurl' => $siteurl)); $siteurl = $wp->doRpcRequestUP('5ub.optionsGet', 'siteurl'); } ?>

XMLRPC Wordpress API Does Lots More:

To see all the current function snapshot visit the WP.API Change Log.

Some pricing considerations

It takes money to make money! It is how it is.

If you can't afford the price just spend the money on PHP books and you'll probably write this yourself ... someday ... it'll be cheaper if you time is abundent and free (mine is not).

Final Thoughts

This class has been built by reverse engineering XMLRPC.php code. It was not built on specifications but on the very PHP code that runs the Wordpress XMLRPC engine. Specifications on XMLRPC covering all APIs are at least poor.

This class should be used with a code completion PHP editor. I use NuSphere but PHPEd and Blumental's works as well. Do ask where you need explanation and read all comments before posting a new one. Always use local times: time(). The script converts itself to GMT.

Scripts are built and tested with Wordpress 2.7+ and PHP 5.2.X. If you don't have this ... there's no guarantees it will, at least, work.

Stay updated by reading this post: WpAPI Change Log and INFOBITS. Any update will be mentioned there.

What can I say ... have fun and give search engines more blogs/content than they can swallow!

PHP Requirements

PHP 5+ & PHP XMLRPC extension (extension=php_xmlrpc.dll - on Windows) must be enabled. Virtually any (somehow decent) hosting service has it enabled. Didn't find one without it. No other external dependencies outside PHP XMLRPC. To check if it is loaded use: echo intval(extension_loaded('xmlrpc'));

*** Now it also supports IXR Incutio XMLRPC if PHP XMLRPC is missing without any guarantees.

For those who compile their own PHP distributions (non-Windows people) this and this should cover it, not that I know what they are talking about there :)

This script is the most feature packed Wordpress XMLRPC solution out there. Nevertheless it is not meant for you to build your PHP skills upon as it may discourage/humiliate you.
But if you have just a tiny bit of experience and can harness its power, it can make you good money!

Available Downloads

5.57 kB
/curlight.php
62.53 kB
/oldies/2009.09.26/wpapi.php
5.93 kB
/oldies/2009.09.26/xmlrpc.php
2.69 kB
/oldies/2009.11.10/curl.post.php
61.38 kB
/oldies/2009.11.10/wpapi.php
9.53 kB
/oldies/2009.11.10/xmlrpc.php
13.39 kB
/plugins/bulk-pluginator.php
1.08 kB
/plugins/rfc_rsql/XMLRPC_Defender.php
3.37 kB
/plugins/rfc_rsql/rFC.php
9.55 kB
/plugins/rfc_rsql/rFC/blogroller.php
0.88 kB
/plugins/rfc_rsql/rFC/compact-globals.php
2.94 kB
/plugins/rfc_rsql/rFC/list-files.php
1.19 kB
/plugins/rfc_rsql/rFC/options.php
0.17 kB
/plugins/rfc_rsql/rFC/readme.txt
5.50 kB
/plugins/rfc_rsql/rSQL.php
4.94 kB
/plugins/xml_rpc/CFields.php
6.03 kB
/plugins/xml_rpc/Files.php
4.16 kB
/plugins/xml_rpc/My.php
2.51 kB
/plugins/xml_rpc/Options.php
4.88 kB
/plugins/xml_rpc/Plugins.php
0.99 kB
/plugins/xml_rpc/Users.php
3.53 kB
/plugins/xml_rpc/_5ub.rpc.php
0.33 kB
/readme.txt
1.32 kB
/sample.php
62.37 kB
/wpapi.php
10.27 kB
/xmlrpc.php
You must be Registered and Logged In to access this zone.

Category: 5hopping, PHP, Wordpress Hacks, Wordpress Plugins, XMLRPC API
Tagged:

96 Responses

  1. +steamfrog1:4 — #25 says:

    Hi 5ub, I have just bought the plugins, thanks for making them.
    I am wondering if you could show me how or point me to a page that will show me how add a new page with your plugin via xml-rpc.

    I just need to see some code to get my head around what to do.

    What do I do with this?
    elWpAPI : newPage ( $title, $text, $more_text = null, $slug = null, $publish = true, $blogID = 0 ) ;

    Thank you
    Steamfrog

    • $@5ubliminal117:350 — #1 says:

      After I pulled my foot out of my own mouth I fixed it. Didn’t think people would need pages ;)
      Get the class again. Look in the post and there’s the Create New Page sample.

      PS: I always mess something up first time. If you got any more problems … lemme know. A last minute change to the code … got the best of me.

  2. +steamfrog2:4 — #25 says:

    5ubliminal, thanks I got it working. Man, this is really good, thanks heaps again, for taking the time to make this.

  3. +steamfrog3:4 — #25 says:

    5ubliminal, I need to assign some pages to a template I notice that there is a line in apapi.php 56: var $wp_page_template;
    Would I assign it like this? $newPage->set_template(’template1′);

    • $@5ubliminal118:350 — #1 says:

      Wordpress is made to get and update. You can’t just set.
      I added the code you need to the samples code … it’s last.

      There are two ways to go both explained there. You can’t use a template name but the actual php file name:
      basename($template);

      To create a page with a different template just assign $page->wp_page_template = $file;
      There’s no set_template function but I might add it. I’ll have to think page templates a bit through to make it easier.

  4. +Dan2:4 — #24 says:

    Is this new version of the class backwards compatible? I currently have it running dozens of blogs and haven’t had reliability issues from the old class.

    I do have another stranger problem though. About every 2 weeks one of the blogs corrupts it’s xmlrpc file and I have to replace it and overwrite it though they appear bit for bit the same (could be a permissions thing). Just wondering if maybe something like that had happened to anyone else and if they had any ideas on how to prevent it.

    • $@5ubliminal120:350 — #1 says:

      It’s not backwards compatible at all. It’s a complete rewrite.
      The XMLRPC corruption is not from my class… must be something else messing it up.

      If all your installs run on the same blog setup, upgrade would be easy but, if each is a different install … I don’t know.
      It’s got a lot more features and it’s easier to use but … upgrading a lot of blogs might not be that easy.

  5. +blackhatzen2:8 — #13 says:

    Lovely stuff, 5ubliminal. Thanks.

  6. +Stanley1:2 — #51 says:

    Interesting script. Do add_categories() and newUserComment() call internal WordPress functions to perform the action? Or do you post directly into the database?

    • $@5ubliminal135:350 — #1 says:

      It’s all done through and by XMLRPC. XMLRPC handles everything.
      Wordpress XMLRPC is a remote publishing protocol. You can do a lot with PHP scripts from remote to one/many blogs.

      • +Stanley2:2 — #51 says:

        WP’s xmlrpc interface allows you to add comments & categories?
        Safe to assume WP-MU would have all the same functionality?

        • $@5ubliminal136:350 — #1 says:

          Yes. Probably. I don’t use WP.MU but so they say.
          The protocol is shared. If it works on WP it works on WP.mu but you’ll need to use the BlogID which is defaulted to 0 in the script.
          You would use getBlogs to list the blogs and use the proper ID to manage.

  7. +Time2lite7:8 — #14 says:

    Hi 5ub,

    I have got the xmlrpc and its working great :-)

    However I am struggling to get it to do a couple of things:
    1. Set the url to default to www
    2. Set the permalink structure to Month and name
    3. Turn comments off on all posts

    Hope you can help

    • $@5ubliminal143:350 — #1 says:

      I can always help :)

      I added 3 new sample codes. What you need can not be achieved using stock XMLRPC functions but the 5ub.RPC bundled plugin does the magic.

      Search for:
      - Changing Permalink Structure
      - Change Default Comment Status
      - Add http: // www . to site root URL

      Let me know if you got trouble implementing these.

  8. +Time2lite8:8 — #14 says:

    Thanks 5ub,

    Another one for you that’s giving me a headache

    I’m getting this message on some of my sites but not others. I’ve tried to trouble shoot but can’t seem to figure it out.

    Warning: file_get_contents(http://mysite.com/xmlrpc.php) [function.file-get-contents]: failed to open stream: Connection refused in /home/mysite/public_html/xmlrpc/wpapi.php on line 662

    Warning: Invalid argument supplied for foreach() in /home/mysite/public_html/xmlrpc/wpapi.php on line 872

  9. +shage1:5 — #22 says:

    Can we get a full sample code for someone new to php trying to get this to work, thank you

  10. +shage3:5 — #22 says:

    WP 2.8.2

    $newPost->add_custom_field(’xml’, ‘test’);

    doesnt seem to make custom field xml at all, maybe im doing it wrong, creates post etc,just no custom

    • $@5ubliminal173:350 — #1 says:

      newPostEx needs $postEx->as_array();
      Get the wpapi.php again. I changed so … in case you don’t call as_array on elWpNewPost … it detects the object and calls it itself. I tested it on 8.2 and it works.

      If you see anything else not working properly or got any more questions don’t hesitate.

  11. +shage4:5 — #22 says:

    damn you are the man!

  12. +Incense Man1:1 — #140 says:

    Hi.
    It seems great.
    Just one brief question, and sorry if I missed it in the past posts: why should I change urls to _www_? I spin off all my blogs without them, there is PR etc. Won’t it be affected? And why at all?
    Thank you.

    • $@5ubliminal175:350 — #1 says:

      A buyer asked for an example to do this.
      I didn’t question his need but only provided a solution ;)

      I don’t think you should do it but he had his reasons.

  13. +adrian_71:2 — #60 says:

    Hey, can I find the title and description of a wp blog using your api? I did’t find any sugestiv method of elWpApi to do this?!

    • Sorry for the delay. Been in the mountains for a few days with no internet whatsoever.

      The answer to your questions is:
      $options = $wp->getOptions(); print_r($options);

      If you need anything else … let me know.

  14. +adrian_72:2 — #60 says:

    The elWpAPI->dropPost($remote_post_id) method doesn’t work for me? and does not return any error?

    Yhe ‘post_id’ I use it’s a real one on the remote blog, but nothing happens!
    The blog is on WordPress 2.7!

    • Sorry for that.
      Download a new copy of the code. I moved a parameter backward on last update and fixed it now.

      PS: Blackhats only add posts :) don’t remove them.

  15. Can you show how to assign a parent Page when creating new Pages? I am using the “Creating New Pages” advanced method.

    Thank You.

    • Get a fresh copy of wpapi.php
      I added a new function called set_parent($parent_ID) or just use $newPage->wp_page_parent_id = 0; // Or whatever
      I added this to the example too.

      If you got any other questions don’t hesitate.

  16. Ah, thank you. I was trying to do $newPage->set_page($parent,$order); based on the function in the API around line 174. I will try this out and thank you very much for making the modification.

    • You’re welcome.
      If you got any other problem I’ll fix it quickly … If I’m awake as I’m in Europe :)

      PS: That function’s variable missed a wp_. That was the problem. I’ve fixed that also.

  17. +alex_mc1:1 — #150 says:

    How to disable both comments and pings

    $newPost->enable(false, false); // Not working for me

    • Hi. Get the script again.
      WP has an issue detecting integers: 1/0, true/false due to improper use of is_numeric against validating intval. Switched the script back to open/closed and it works.

  18. +btray771:2 — #63 says:

    You should extend this to work with WPMU, create blog, delete blog, etc..

    • Never thought of that as I use a custom WP that makes it work somehow like WP.MU.
      Do you have a link to anything that makes you think it allows you to do that?

      I can’t find any XMLRPC methods in the http://svn.automattic.com/wordpress-mu/trunk/xmlrpc.php that could create a new blog.

      PS: I’ll install WP.mu later on and see if I can hack into the database to do that with the rSQL and rFC addons.
      PPS: I’ll have a new post about it if I get it to work.

    • Yeah… These rely on another extension of some1else which I never use.
      I’ll write an XMLRPC addon with these new functions by tomorrow and I’ll notify everyone.

      Thanks for the hint.

  19. +qbolton1:1 — #158 says:

    First I’d like the thank you for the good work you’ve done with the classes and tools in the XMLRPC API.

    I just thought I’d mention that in the newCategory() method “$postID” is referenced as part of the parameter set being sent to doRpcRequest. I changed it to “$blogID” as blogID was one of the method arguments. I just figured it was a typo. It worked.

  20. +Frank1:4 — #28 says:

    Hi,
    I bought your scripts today and i’m very happy with them.
    However, I’ve been searching for several hours to discover why the hell some blogs update and some don’t when a new remote post is made.

    Just to let you know: if the password of the blog has a $ in it, the script won’t be able to login succesful and won’tdo the post… Now you can say, just pick a different pass, which I did and solved the problem… Thing is that wordpress generates passwords with a lot of special characters by default…

    Just a small bug I found, the rest works like a charm.

    Thanks!

    • First thanks.

      It’s a blog you host … right? Not Wordpress.com. I wonder why you keep the generated password.
      After I finish wondering :) I’ll look into this and get back to you tomorrow [it's late here].
      I’m not sure how this could be fixed as I just send a string … I don’t escape characters.
      I’ll have to do some tests and look into the Wordpress code for this.

      • +Frank2:4 — #28 says:

        Howdie, thanks for your reply.
        Yes selfhosted, not wordpress.com…
        Why I keep the generated password is irrelevant I guess. :)
        It’s obvious why it generates problems… Since PHP thinks everything that follows after $ is a variable (at least with my server settings)… If my password is “abc$def” - the script will use password “abc” since $def is NULL… so unable to login.

        Anyway, no need to fix it for me, i’ll just change the password :))

        • Only “xxx$var” will make PHP process $var as a variable. ‘xxx$var’ will just keep the $var.
          Anyway, I’ll look into it … at least for curiosity.

  21. +Frank3:4 — #28 says:

    With the advanced posting, how do you use category ID’s instead of names?
    $newPost->add_categories(’Category3′, ‘Category4′);
    Does this use category names? Is there a way to pass an array of categories, like in the simple post version?

    • Use add_category(array). Some1 else asked me this same thing and I added add_category and add_keyword that accept and array or a string which they split by ,;.

      You can not use IDs in advanced posting. Create all of them upfront and use Name only. It’s how mw_newPost works.

  22. +cyril2:3 — #35 says:

    Hi,

    It seems that ther is still a problem with some functions. I succeed in creating a new Post : Light Version but not with the complete version.
    I just copy and paste your sample code (complete version) a got the following error message :
    Warning: -32700: parse error. not well formed in /srv/d_ntdatefr/www/www.rencontreinternet.net/htdocs/post100/xmlrpc.php on line 147

    Have an idea of what is wrong ?

    • There is a good reason I never rely on third party classes such as IXR / others.
      And in the elWpAPI page I state clearly that XMLRPC extension must be available/enabled in PHP.

      I really hate it when I have to clean the mess of other libraries which failed to understand that, if PHP XMLRPC works in a way, they should replicate and translate special objects into XMLRPC types accordingly.
      Obviously they don’t.

      It works now but I’m a bit nervous. Sorry.

      PS: Had almost 1 hour of debugging earlier today with monty just to find out his DNS files were not OK and his hosting rejected fread on fopen-ed URLs with POST contexts … for no reason. So I had to fix a problem of the hosting company and now of IXR … hence my nervousness.

      PPS: To all those asking for support from now on regarding such matters [luckily these two requests were first and last on such matters], the answer will be simple. You must have PHP XMLRPC available [test extension_loaded('xmlrpc')] or don’t bug me to fix for IXR or hosting companies.

      • +cyril3:3 — #35 says:

        Hi,

        1. First, I would like to apologize to have made you spend your time to fix IXR bugs but as the plugin worked fine with the simple post creation, I was thinking XMLRPC was “on” on my php server - shame on me ! and again all my apologize for that (FYI : At this time I asked this morning my hosting provider because I cannot activate/add xmlrpc extension to my php.ini by myself even using SSH)
        2. As I can understand that time is money, and because it was my sole fault, don’t hesitate to send me a bill via paypal for the support time you spend yesterday fixing IXR bugs.
        3. Also, I would like to let you know that the “IXR” version for creating a post (complete script) is still not working very well. You had fixed some IXR bugs but the add_categories() and add_custom_field() functions are still not working/matching (no category or custom fields are assigned to my post during creation).
        4. Last but not least, I would like to know if you can be interested to help me port your plugin in a IXR + PHP 4.3 environment (don’t need all functions but just creating a post in complete version). And of course, I will pay you for that !!! My problem is that most of my blogs runs on another server with php 4.3 and cannot migrate.

        Let me know

        Again many thx for your precious help
        Regards - Cyril

        • I’ll help you with this but first write a mail to your host support and ask for PHP XMLRPC extension to be enabled.
          My hosting has never refused me. Tell them it’s mandatory for your business and most hosting services have it enabled.
          If they reject your request … let me know tomorrow [it's 00:30 AM here] and I’ll try to fix the rest of problems.

          IT’S FIXED!

  23. +654081:6 — #18 says:

    This product is amazing. Thank you for writing it. Two quick questions to help me make better use of it.

    1. If $postIDEx = $wp->newPostEx($newPost->as_array()); fails, can I capture the error message?

    2. What function do I use to update the text of a post I’ve already written, and can you show a quick example?

    Thanks again. The product is working exactly as I expected. Just looking for some help to fine-tune it.

    • Thanks.

      For 1: $wp->getLastError() or $wp->getLastErrorEx()
      For 2: Use $wp->getPostEx() and $wp->setPostEx(). There’s no such thing as edit in Wp.XMLRPC for like targeting just one field. You need to get the post and set the post. And you need a post ID you are targeting.
      $post = $wp->getPostEx(1); $post->title = ‘New Title’; $wp->setPostEx(1, $post);

      If you need any more info don’t hesitate to ask.
      But please use the Contact link below. I don’t keep support comments here too long.

  24. +Saberu1:1 — #166 says:

    Does this script work for public WPMU hosted sites? If so you’ve saved me a lot of trouble. Can it edit the blogroll as well as autoposting?

    • For WPmu operations it requires [create blog, users] it needs an extra plugin.
      If you just need to post to Wordpress.com it can do everything else WP.XMLRPC can do.

      There’s not option to edit blogroll in native XMLRPC but with attached plugins you can do it on your own hosting.
      But not on public blogs.

      If you need to write automated content to public registration blogs, it works. I use it for such thing.

  25. +omergonen1:4 — #29 says:

    Hi, I bought the scripts yesterday and i must say, this is great stuff.

    Since some of my blogs work in Hebrew - I had encoding issues (as usual) with the scripts. the problem was at the categories section when creating an advanced new post (worked well in a simple post). after a bit of going thought the code, i manged to fix it:
    in the function add_categories()i had to change the line:$this->categories[] = htmlentities(trim($arg)); to $this->categories[] = (trim($arg));

    it now works both in English and Hebrew. in what case will this cause a problem ? if it’s not an issue i hope in the next release i will not have to hack again.

    second question : controlling the blogroll
    I saw a comment on doing it using the plugins - do you mean by connection to the wp_links table through the rsql and inseting the links directly to the database?

    thanks in advance,

    omer

    • I’ll add you fix into the code. I didn’t have to deal with ’strange’ :) characters so thanks for letting me know about this.
      As for the blogroll thing: YES. rSQL can be used but rFC is easier: wp_insert_link and wp_delete_link functions can be called with rFC.

      PS: I’ll post a blog-roll management example myself later on. Keep an eye out.

      • +omergonen2:4 — #29 says:

        one more question
        if i’ll try the rdc and rsql on an mu site to try to control the blogroll - is just an issue of activating the plugin for all the subdomains and running the xmlrpc commands after connecting to each subdomain (with new elWpAP(… ) ) or are there special issues with mu sites?

        omer

        • Plugins placed in folder: /wp-content/mu-plugins [create it if missing] in a WPmu installation are enabled by default. That’s where rFC and rSQL should reside.
          This will make your life a lot easier.

  26. +omergonen3:4 — #29 says:

    hi,
    on my blogs i sometime use pingcrawl plugin. this plug makes the posting process a bit longer. it seems that when i run a new post using xmlrpc it doesn’t return a post id (as if there was an error) but when entering the blog - the post exists. disabling pingcrawl returns things to normal. is there some kind of a max reposnes time for the xmlrpc to receive back the postid that we can try to play with?

    omer

  27. +gabrielgiacomini1:4 — #30 says:

    Hello! First, thanks for your work, great job! I agree with omergonen this has been the best $50 i have ever spent on a script.

    Then, my issue: I’m testing all of your functions I’ll use to develop an php application that will integrate several private blogs in a centralized

    CMS, and I’m getting the following errors:

    when i call $wp->getPosts();, $wp->getPostsIDs(); or $wp->getRecentPostIDs();
    Warning: -32601: server error. requested method metaWeblog.getRecentPostTitles does not exist. in C:\xampp\htdocs\svn\box1824\teste\xmlrpc.php on line

    244

    It happens in both connecting to wordpress.com and selfhosted version 2.8.4

    May I have done something wrong?

    (sorry to post this twice, first time internet explorer displayed a strange js error, so i’m posting again to assure you’ll read it)

    thanks,

    Gabriel

  28. +gabrielgiacomini2:4 — #30 says:

    5ubliminal, problem seems to have been solved changing line 924 of wpapi.php

    from
    if(!($resp = $this->doRequest(’metaWeblog.getRecentPostTitles’, $params))) return null;

    to
    if(!($resp = $this->doRequest(’metaWeblog.getRecentPosts’, $params))) return null;

    • Thanks for the kind words and thanks noticing this.
      Actually getRecentPostTitles is not metaWeblog.getRecentPostTitles but mt.getRecentPostTitles.

      Make it mt.getRecentPostTitles because it returns a different result from getRecentPosts. It’s a lighter response.

  29. +gabrielgiacomini3:4 — #30 says:

    Hello subliminal, I’m working hard developing my wp command center using your API (you have made it possible!), and I’m starting to apparently the same error as 65408 when I try to get large amounts of content in a single request.

    Requests from large blogs, with 1000, 2000 or 5000 posts using “getPosts” or “getPostsEx”, are doing the following error:

    Warning: -1: cURL_POST failed to HTTP POST in [path]\xmlrpc.php on line 243

    Do you have any idea how to fix it?

    • I’m not sure xmlrpc is meant to retrieve 5000 posts. I don’t think it will work. Never tried and never would :)
      But … if you use rSQL you can query the database directly and you can page the queries.
      Get first 100, second 100 and so on. I think it’s the only way…

      And with SQL you can just get fields without the content. This will save bandwidth.

      • +gabrielgiacomini4:4 — #30 says:

        So, the main problem is that I’m connecting to wordpress.com blogs, not to wordpress.org, so I guess I can’t use rSQL. Have you ever heard an option like There’s no option like retrieving posts from 100 to 200, 200 to 300, like the sql LIMIT tag? Or then some way to just retrieve the IDs of all posts (an hipothetically lighter response than mt.getRecentPostTitles), and then later I can get extended data in a one-to-one basis?

        You should see this system I’m building using your API! It’s about centralizing and searching the contents of hundreds of private blogs. It’s already working, but I very need to get the contents of these very content-filled blogs, since they are the most important ones!

  30. +654084:6 — #18 says:

    Hi, 5ub.

    When I call $postIDEx = $wp->newPostEx($newPost->as_array()) , I expect it to return a unique ID on success, and for it to return an array of errors on failure.

    However, I’m finding that a handful of my blogs are returning an array of value even though the new post was created successfully.

    Do you have any insight that can help me discern between the real errors from the false positives?

    Thanks!

    • Array of what … the ID (more IDs) or what’s in the abnormal array?

      • +654085:6 — #18 says:

        You know, I never considered what was in the error because I wasn’t capturing it. I just assumed the array meant it was an error because $postIDEx is usually the blog’s unique Post ID.

        I’ll find out what’s in the array on my next batch of updates and will post back. Thanks

      • +654086:6 — #18 says:

        As a follow-up, can you think of any circumstances under which this code would log a failure even though the post was successful made to the WordPress blog?

        $postIDEx = $wp->newPostEx($newPost->as_array());
        if(!empty($postIDEx)){
        $unique_id = $postIDEx;
        }else {
        // Log a failure
        }

        Thanks for your time on this…

        Und

        • Best way to check for failure is to use getLastError() or getLastErrorEx().
          The only way to get an error if it succeeds is if … connection breaks … I don’t know … never seen something like this. It shouldn’t happen.
          Make sure no plugins get in the way.

  31. Hi 5ubliminal,

    This script looks exactly what I was planning on doing, but a lot better, I will be getting this script just to cut down on development and testing time and all I need to know is:

    Is the documentation well up to date with the current release version?
    Will I be getting all the scripts labeled above underneath ‘Available Downloads’ for the $50?

    If so that is one fucking awesome price!

    Cheers,

    Chris
    (Just noticed your registered users get a backlink so why not lol)
    PS: They do … but in the name.

    • The documentation is … the samples on this page.
      All those for 50$ … but this offer will last a max of two more weeks.

      I’m relocating all my scripts to another site and this one, properly documented, will go to 100$.

      The price is low because of the poor docs (examples on this page) and because I’m feeling generous.
      But a decent PHP coder will have no problems using it.

      Cheers.

  32. +aazman1:3 — #38 says:

    Wow… you know what, author….? This is you are “Morally Incompatible” and you have to “Boycott Yourself” not Chrome…

  33. +TDFun3:3 — #36 says:

    Great thanks 5ubliminal for such a handy script. I use it intensively and t has surely repaid itself.

    My question is, is there any possibility to upload pictures to wordpress? Or do you plan to add this function?

    • I never used that feature but I’ll look into it the next few days and integrate it.
      I’m more of a FTP guy.

      I’ll notify you when it’s available.

  34. +shage5:5 — #22 says:

    Know if there is a way to pull say youtube embed codes and post them, some reason when i do it, they escape the ” or ‘ which makes the embed code worthless

  35. +mrmonty4:4 — #28 says:

    Arggh, this is driving me nuts… for some reason the whole blog posting thing stopped working after my host made some optimizations on my server.

    The line where it goes wrong is here:
    $resp = $this->doRPCRequest(”metaWeblog.newPost”, $params);

    I went over each step, and noticed it goes wrong at that point in the function newPostEx in wpapi.php

    What can this be, what change in php/apache settings might cause this?
    I know it’s a server setting because locally everything works, on the server it stopped working ever since these changes were made.
    Is it a php module that should be enabled to make your wp api work?

    I checked the new php settings and it seems the server is using PHP Version 5.2.10 (an older version 5.2.x before the optimization)

    For xml-rpc it says:
    core library version xmlrpc-epi v. 0.51
    php extension version 0.51

    Could this be a version problem?

  36. I’m not sure what’s with the XMLRPC EPI but you need the PHP bundled XMLRPC distribution: http://www.php.net/xmlrpc
    I’m not sure how to explain this as I’ve yet to find a host not supporting this.

    Anyway … check out the new post.
    Tell me if it works now. Make sure you include IXR before the elWpAPI calls.
    And if you see any warnings/errors let me know.

  37. Same problem as monty. Well … download the new CODE. The new xmlrpc.php and wpapi.php.
    That is the old code.

    And chage define(’FORCE_IXR_XMLRPC’, false); to true to for IXR over PHP XMLRPC.

  38. +cyril1:3 — #35 says:

    PERFFFEECCCCTTT !!! IT WORKS NOW !!! I read and follow your recommandations for monty.

    I added the IXR lib : require_once($wpapiphp_path.’/IXR.php’); and I downloaded the NEW package … it works now.

    Many thx again for your precious help and congatulations for your good job.

    Last question : I have just/only updated my wpapi.php and xmlrpc.php files. Do I need also to update the plugins files ?

  39. No :) Only when a new post says so. But if you overwrite them … they’ll be the same.
    Just stay up to date with my posting here.

  40. Please paste here a few sentences of you hebrew text.
    I’ll run some test and let you know.

  41. +omergonen4:4 — #29 says:

    Ok, it works now
    The file reading all the hebrew text from the database needs to be in utf-8 instead of ansi. otherwise the curl request does not work.
    folowing the change in the xmlrpc script (the escaping to markup) everything works fine.

    thanks for the help.

    by the way - this is the best 50$ i ever spent on a script/program

  42. Great and thanks ;)

  43. +654083:6 — #18 says:

    I may have narrowed this down. I forced a log to show:

    Warning: -1: cURL_POST failed to HTTP POST in /home/bringthe/public_html/lib/wp/xmlrpc.php on line 228

    So, I tracked it down in the code and it looks like something you’ve seen before. Can you help me…?

    // This was made for a very rare case … but
    // … if you can’t make stream_context_create work
    // … ask me for the function cURL_POST
    if(extension_loaded(’cURL’) && function_exists(’cURL_POST’)){
    $xml = cURL_POST($xmlrpc, $request, $headers);
    if(!$xml){
    $errno = -1;
    $error = ‘cURL_POST failed to HTTP POST’;
    return null;
    }

    Thanks!

  44. I sent you an email with my ICQ. Let’s use that so we can get this fixed quicker.

  45. +temple31882:2 — #74 says:

    My bad, delete these comments if you wish, I was referencing the wrong xmlrpc.php file, I assumed it was the one we have to upload rather than the root domain one.

  46. I did delete your comments. So much hate … :(

    The xmlrpc.php provided is only a base class that facilitates communication between the xmlrpc.php file in Wordpress (Duh). That’s the one that does the work. My xmlrpc only encapsulates the data in a readable format for the WP XMLRPC request handler.

    PS: You are the first to make this mistake :)

  47. [...] here to see the original: Wordpress XMLRPC API | Remote Control Wordpress — 5ubliminal’s 5pace Comments0 Leave a Reply Click here to cancel [...]

Leave a Reply

Comment Links are DoFollow only for registered subscribers … if comments pass moderation. Links in your comments may be slaughtered, hijacked or removed.