Group Admins

WordPress Troubleshooting and Support

Public Group active 1 year, 5 months ago ago

WordPress support from our community

XMLRPC – Adding a Post via the WordPress API

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1308
    Richard Moon

    I have a standard WordPress site running on Hostgator. I am trying to add a post from an external php application. I am using class.bloggerclient.php in conjunction with xmlrpc.php that comes with WordPress. Rather than adding a post as it should I am getting the following error: “XML-RPC server accepts POST requests only.”.

    Does anyone have experience adding a post from an external application? Is there a better approach for doing this successfully?

    ********* Here is the php application code:


    $username = “myusername”;
    $password = “mypassword”;

    $blog = new bloggerclient($username, $password);
    $blogID = “12345”;
    $testPost = “This is the post that I am trying to add!!”;
    $publish = true;

    $myPost = $blog->newPost($blogID, $textPost, $publish);

    ********* First few lines of the class.bloggerclient.php file:


    class bloggerclient {

    var $bServer = “”;
    var $bPath = “/xmlrpc.php”;
    var $apiName = “blogger”;
    var $blogClient;
    var $XMLappID;
    var $XMLusername;
    var $XMLpassword;

    D.K. Smith

    Try this first:

    1. Rename the following code “rpctest.php”

    Note: Replace “& lt;” and “& gt;” with less-than and greater-than symbols.

    // XMLRPC Remote Publishing TESTER –
    header(‘Content-Type: text/plain’);
    echo ‘PHP: ‘, (version_compare(PHP_VERSION, ‘5.2’, ‘>=’) ? ‘compatible’ : ‘needs updating’), PHP_EOL;
    echo ‘ionCube Loader: ‘, (extension_loaded(‘ionCube Loader’) ? ‘a-okay’ : ‘not working’), PHP_EOL;
    echo ‘cURL HTTP Client: ‘, (extension_loaded(‘curl’) ? ‘a-okay’ : ‘not working’), PHP_EOL;
    echo ‘ZIP: ‘, (extension_loaded(‘zip’) ? ‘a-okay’ : ‘not working’), PHP_EOL;
    echo ‘XMLRPC: ‘, (extension_loaded(‘xmlrpc’) ? ‘a-okay’ : ‘not working’), PHP_EOL;

    Upload to your site’s root and call it from a browser. You want to see that everything is working.

    Richard Moon

    Thanks D.K. Here is the output:

    PHP: needs updating
    ionCube Loader: a-okay
    cURL HTTP Client: a-okay
    ZIP: a-okay
    XMLRPC: a-okay

    Even though it says “PHP: needs updating”, I don’t think that is an issue. I did a phpinfo() which confirmed the following: PHP Version 5.2.17.

    Richard Moon

    f.y.i. I came across this:

    This is what the beginning of my xmlrpc.php file looks like:

    define(‘XMLRPC_REQUEST’, true);

    // Some browser-embedded clients send cookies. We don’t want them.
    $_COOKIE = array();

    // A bug in PHP < 5.2.2 makes $HTTP_RAW_POST_DATA not set by default,
    // but we can do it ourself.
    if ( !isset( $HTTP_RAW_POST_DATA ) ) {
    $HTTP_RAW_POST_DATA = file_get_contents( ‘php://input’ );

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.