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:
Parameters
    int blog_id
    string username
    string password
    int post_id
    struct comment
        int comment_parent
        string content
        string author
        string author_url
        string author_email 
The following code should be enough to post a new comment on wordpress 3.3.5 (XML-RPC_wp api v3.1) via xmlrpc:
<?     
include('IXR_Library.php.inc');
    $client = new IXR_Client('http://myblog.com/xmlrpc.php');
    $time = date("Ymd")."T".date("H:i:s")."Z";
    $post_id = "630";
    $data = array(
    'author' => 'test_author',
    'author_email' => 'test_comment@scroogle.org',
    'author_url' => 'http://www.scroogle.org',
    'content' => 'Comentario Teste <a href="http://www.scroogle.org">scroogle.org</a>',
    'date' => $time,
    'approved' => 1,
    );
    if (!$client->query('wp.newComment','', '','',$post_id, $data)) {
    die('An error occurred - '.$client->getErrorCode().":".$client->getErrorMessage());
    }
    $result = $client->wp_insert_comment($data);
    print_r($result);
?>
Note: In order to post anonymous comments via xmlrpc you'll need WordPress – Anonymous XMLRPC Comments Plugin
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论