WordPress Troubleshooting and Support
Public Group active 10 months, 1 week ago agoWordPress support from our community
XMLRPC – Adding a Post via the WordPress API
- This topic has 3 replies, 2 voices, and was last updated 10 years, 9 months ago by
Richard Moon.
-
AuthorPosts
-
November 9, 2011 at 1:09 am #1308
Richard Moon
ParticipantI 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:
include_once(“class.bloggerclient.php”);
$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:
require_once(“xmlrpc.php”);
class bloggerclient {
var $appID = “YOU MUST PLACE YOUR BLOGGER API KEY HERE”;
var $bServer = “mysite.com”;
var $bPath = “/xmlrpc.php”;
var $apiName = “blogger”;
var $blogClient;
var $XMLappID;
var $XMLusername;
var $XMLpassword;November 9, 2011 at 3:41 pm #2254D.K. Smith
ParticipantTry this first:
1. Rename the following code “rpctest.php”
Note: Replace “& lt;” and “& gt;” with less-than and greater-than symbols.
Code:<?php
// XMLRPC Remote Publishing TESTER – WPSecurity.com
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.
November 12, 2011 at 7:52 pm #2256Richard Moon
ParticipantThanks D.K. Here is the output:
PHP: needs updating
ionCube Loader: a-okay
cURL HTTP Client: a-okay
ZIP: a-okay
XMLRPC: a-okayEven 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.
November 12, 2011 at 8:08 pm #2257Richard Moon
Participantf.y.i. I came across this:
http://foliovision.com/2007/05/19/xml-rpc-server-wordpress-error
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’ );
} -
AuthorPosts
- You must be logged in to reply to this topic.