Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

XML-RPC/wp.getComment

wp.getComment

Get comment data

Availability

WordPress 2.7+

Parameters

  • (string) blog_id
  • (string) username
  • (string) password
  • (int) comment_id

Response

  • (dateTime.iso8601) date_created_gmt
  • (int) user_id
  • (int) comment_id
  • (int) parent
  • (string) status (approve, hold, spam)
  • (string) content
  • (string) link
  • (int) post_id
  • (string) post_title
  • (string) author
  • (string) author_url
  • (string) author_email
  • (string) author_ip
  • (string) type (<empty>, trackback, pingback)

Example Request


<methodCall>
    <methodName>wp.getComment</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>
                <int>8</int>
            </value>
        </param>
    </params>
</methodCall>

Example Response



<methodResponse>
    <params>
        <param>
            <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>More (http://msdn.microsoft.com/en-us/library/aa752574(VS.85).aspx) tests.</string>
                        </value>
                    </member>
                    <member>
                        <name>link</name>
                        <value>
                            <string>http://example.com/?p=1#comment-8</string>
                        </value>
                    </member>
                    <member>
                        <name>post_id</name>
                        <value>
                            <string>1</string>
                        </value>
                    </member>
                    <member>
                        <name>post_title</name>
                        <value>
                            <string>Link Test</string>
                        </value>
                    </member>
                    <member>
                        <name>author</name>
                        <value>
                            <string>xmlrpc-example</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>127.0.0.1</string>
                        </value>
                    </member>
                    <member>
                        <name>type</name>
                        <value>
                            <string></string>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodResponse>

PHP Example


<?php
require "./IXR_Library.inc.php";

$rpc = new IXR_Client( "http://example.com/xmlrpc.php" );
$status = $rpc->query(
    "wp.getComment",    // method name
    "1",                // blog id
    "xmlrpc-example",   // username
    "example-password", // password
    1                   // comment id
);

if( !$status ) {
    print "Error ( " . $rpc->getErrorCode( ) . " ) : ";
    print $rpc->getErrorMessage( ) . "\n";
    exit;
}

$data = $rpc->getResponse( );
print_r( $data );