• I’ve been hunting unsuccessfully to find a way to post automatically to my wordpress blog using XMLRPC in PHP.

    Can anyone point me to a specific working example of using php to take an xml blog post and submit it to a wordpress blog on wordpress.com?

    So far every example I have tried utilizing gives me the exact same error message:

    “XML-RPC server accepts POST requests only.”

    I would appreciate anything that would help point me toward a working solution.

    This is an example of one of my previous attempts. This is exactly how I used it except I inserted my actual username and password.

    $c = new xmlrpc_client(“/xmlrpc.php”, “dancinandy.wordpress.com”);

    $content[‘title’]=”Test Post”;
    $content[‘description’]=”This is a test post”;
    $content[‘categories’] = array(“frontpage”);
    $x = new xmlrpcmsg(“metaWeblog.newPost”,
    array(php_xmlrpc_encode(“1”),
    php_xmlrpc_encode(“USERNAME”),
    php_xmlrpc_encode(“PASSWORD”),
    php_xmlrpc_encode($content),
    php_xmlrpc_encode(“1”)));

    $c->return_type = ‘phpvals’;
    $r =$c->send($x);
    if ($r->errno==”0″)
    echo “Successfully Posted”;
    else {
    echo “There are some error”;
    print_r($r);
    }

Viewing 4 replies - 1 through 4 (of 4 total)
  • http://codex.wordpress.org/XML-RPC_Support

    Some links there that you may find helpful?

    More at Weblog_Client as well.

    I’ve only done this with old versions of WP and found it only worked when using Blogger methods. Below is the code I used, maybe it will be of some help to you.

    $client = new xmlrpc_client($xmlrpcurl);
    
    $params[] = new xmlrpcval("n/a");
    $params[] = new xmlrpcval("n/a");
    $params[] = new xmlrpcval($username);
    $params[] = new xmlrpcval($password);
    $params[] = new xmlrpcval("<title>" . $postTitle . "</title>" . $postContent);
    $params[] = new xmlrpcval(false);
    
    $msg = new xmlrpcmsg("blogger.newPost",$params);
    
    $response = $client->send($msg);
    
    if ( $response->errno == 0 ){
    	print 'Success';
    } else {
    	print 'Fail';
    }
    Thread Starter crash97

    (@crash97)

    HandySolo,

    I’ve tried looking through the xmlrpc support page but most of the links turn into dead ends on xmlrpc.com which seems to have a lot of missing pages. I haven’t found anything terribly useful on wordpress’s support pages and I’ve tried emailing for help, but they simply tell me they don’t give any help with coding.

    triffid,

    Your code is similar to one of my attempts, but I copied it and tried it anyway. I get the exact same message: “XML-RPC server accepts POST requests only.”

    This message is really frustrating me 🙁

    Surely someone has or knows of a working example of php using xmlrpc to post on wordpress.com

    You might try the workaround noted here: http://mu.wordpress.org/forums/topic.php?id=4934&page&replies=1/.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Posting New Blog entries via XMLRPC in PHP’ is closed to new replies.