Get data on multiple comments.
WordPress 2.7+
wp.getComments will return comments from newest to oldest. If you don't provide a filter['number'] value then it will limit the response to 10. These parameters can be used in combination, for instance to get up to 100 (filter['number'] = 100) of the spam comments (filter['status'] = 'spam') for a specific post (filter['post_id'] = 1 ).
Each array item is the same as the result of an XML-RPC/wp.getComment call.
The date_created_gmt field is always the GMT date, even if no time zone information is present. An empty type field indicates a regular comment.
<?xml version="1.0"?> <methodCall> <methodName>wp.getComments</methodName> <params> <param> <value> <string>1</string> </value> </param> <param> <value> <string>xmlrpc-example</string> </value> </param> <param> <value> <string>example-password</string> </value> </param> <param> <value> <struct> <member> <name>post_id</name> <value> <int>41</int> </value> </member> </struct> </value> </param> </params> </methodCall>
<?xml version="1.0"?> <methodResponse> <params> <param> <value> <array> <data> <value> <struct> <member> <name>date_created_gmt</name> <value> <dateTime.iso8601>20081121T02:54:08</dateTime.iso8601> </value> </member> <member> <name>user_id</name> <value> <string>1</string> </value> </member> <member> <name>comment_id</name> <value> <string>8</string> </value> </member> <member> <name>parent</name> <value> <string>0</string> </value> </member> <member> <name>status</name> <value> <string>approve</string> </value> </member> <member> <name>content</name> <value> <string>Need more comments.</string> </value> </member> <member> <name>link</name> <value> <string>http://example.com/?p=41&cpage=1#comment-8</string> </value> </member> <member> <name>post_id</name> <value> <string>41</string> </value> </member> <member> <name>post_title</name> <value> <string>This is a test post</string> </value> </member> <member> <name>author</name> <value> <string>admin</string> </value> </member> <member> <name>author_url</name> <value> <string>http://example.com/</string> </value> </member> <member> <name>author_email</name> <value> <string>example@example.com</string> </value> </member> <member> <name>author_ip</name> <value> <string>::1</string> </value> </member> <member> <name>type</name> <value> <string/> </value> </member> </struct> </value> <value> <struct> <member> <name>date_created_gmt</name> <value> <dateTime.iso8601>20081120T23:49:42</dateTime.iso8601> </value> </member> <member> <name>user_id</name> <value> <string>1</string> </value> </member> <member> <name>comment_id</name> <value> <string>7</string> </value> </member> <member> <name>parent</name> <value> <string>0</string> </value> </member> <member> <name>status</name> <value> <string>approve</string> </value> </member> <member> <name>content</name> <value> <string>Yet another comment.</string> </value> </member> <member> <name>link</name> <value> <string>http://example.com/?p=41&cpage=1#comment-7</string> </value> </member> <member> <name>post_id</name> <value> <string>41</string> </value> </member> <member> <name>post_title</name> <value> <string>This is a test post</string> </value> </member> <member> <name>author</name> <value> <string>admin</string> </value> </member> <member> <name>author_url</name> <value> <string>http://example.com/</string> </value> </member> <member> <name>author_email</name> <value> <string>example@example.com</string> </value> </member> <member> <name>author_ip</name> <value> <string>::1</string> </value> </member> <member> <name>type</name> <value> <string/> </value> </member> </struct> </value> </data> </array> </value> </param> </params> </methodResponse>
require "./IXR_Library.inc.php"; $rpc = new IXR_Client( "http://example.com/xmlrpc.php" ); $status = $rpc->query( "wp.getComments", // method name "1", // blog id "xmlrpc-example", // username "example-password", // password array( "post_id" => 41 ) ); if( !$status ) { print "Error ( " . $rpc->getErrorCode( ) . " ) : "; print $rpc->getErrorMessage( ) . "\n"; exit; } $comment = $rpc->getResponse( ); print_r( $comment );