I have a code like this.
<?php
include('IXR_Library.php');
$client = new IXR_Client('http://127.0.0.1/wordpress/xmlrpc.php');
$data = array(
'comment_post_ID' => 1,
'comment_author' => 'test_author',
'comment_author_email' => 'test@gmail.com',
'comment_author_url' => 'http://test.limewebs.com',
'comment_content' => 'Test Content',
'comment_type' => '',
'comment_parent' => 0,
'user_id' => 1,
'comment_author_IP' => '127.0.0.1',
'comment_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)',
'comment_date' => $time,
'comment_approved' => 1,
);
if (!$client->query('wp.newComment','', 'username','password','12',$data)) {
die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
}
$result = $client->wp_insert_comment($data);
print_r($result);
?>
In the above code, I get my comment posted to WordPress site, but the content(comment_content) is not getting posted.
Dude, remove all ‘comment_’ prefix to your array properties. Writing the WpAPI Class I dug deep in the heart of WP’s XMLRPC. Parameters are always never in the order an normal person would put them. The names used are not consistent either. It’s not a guessing game. Always look at the WP core code when not sure… [or use my Class ;)]
You’re using invalid parameters on your request.
WordPress XML-RPC_wp documentation lists the following parameters has valid for wp.newComment requests:
The following code should be enough to post a new comment on wordpress 3.3.5 (XML-RPC_wp api v3.1) via xmlrpc:
Note: In order to post anonymous comments via xmlrpc you’ll need WordPress â Anonymous XMLRPC Comments Plugin