<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title></title>
  </head>

  <body>
    <p style="margin: 0px;">You're certainly going about this the hard way.  Why not just use the IXR library already bundled with WordPress?</p>

    <p style="margin: 0px;"> </p>

    <p style="margin: 0px;"><?php</p>

    <p style="margin: 0px;"> </p>

    <p style="margin: 0px;">include_once(ABSPATH . WPINC . '/class-IXR.php');<br />
    <br />
    $rpc = new IXR_Client( "http://wpmu.localhost/xmlrpc.php" );<br />
    $status = $rpc->query(<br />
        "wp.getComments",   // method name<br />
        "2",                // blog id<br />
        "admin",   // username<br />
        "disney75", // password</p>

    <p style="margin: 0px;">    array(<br />
            "status"   => "approve"<br />
        )<br />
    );<br />
    <br />
    if( !$status ) {<br />
        print "Error ( " . $rpc->getErrorCode( ) . " ) : ";<br />
        print $rpc->getErrorMessage( ) . "\n";<br />
        exit;<br />
    }<br />
    <br />
    $response= $rpc->getResponse( );<br />
    print_r( $response );</p>

    <p style="margin: 0px;"> </p>

    <p style="margin: 0px;">?></p>

    <p style="margin: 0px;"> </p>

    <p style="margin: 0px;">This is a tested setup and should work regardless of any issue you might face instantiating a CURL request and setting your headers from scratch.<br />
    <span></span></p>

    <p> </p>

    <div style="margin: 5px 0px 5px 0px; font-family: monospace;">
      On May 14, 2010 at 3:57 PM Luke Mackenzie <luke@lukem.co.uk> wrote:<br />
      <br />
      > Thanks again,<br />
      ><br />
      > Can anyone confirm if the blog_id parameter should work in the wp.getComments call? This is what I'm doing to test it:<br />
      ><br />
      > I've tried passing the blog ID as both a string and an integer. Wordpress MU version is 2.9.2<br />
      ><br />
      > I always get the comments from the default blog.<br />
      ><br />
      > <?php<br />
      ><br />
      > error_reporting(E_ALL);<br />
      ><br />
      > $method= 'wp.getComments';<br />
      ><br />
      > $username = 'admin';<br />
      ><br />
      > $password = 'disney75';<br />
      ><br />
      ><br />
      > $blog_id = 2;<br />
      ><br />
      > $params = array($blog_id, $username, $password, array('status'=>'approve'));<br />
      ><br />
      > $service_url = 'http://wpmu.localhost/xmlrpc.php';<br />
      ><br />
      > //Using the XML-RPC extension to format the XML package<br />
      ><br />
      > $request = xmlrpc_encode_request($method, $params);<br />
      ><br />
      > //var_dump($request);<br />
      ><br />
      > $req = curl_init($service_url);<br />
      ><br />
      > // Using the cURL extension to send it off,  first creating a custom header block<br />
      ><br />
      > $headers = array();<br />
      ><br />
      > array_push($headers,"Content-Type: text/xml");<br />
      ><br />
      > array_push($headers,"Content-Length: ".strlen($request));<br />
      ><br />
      > array_push($headers,"\r\n");<br />
      ><br />
      > //URL to post to<br />
      ><br />
      > curl_setopt($req, CURLOPT_URL, $service_url);<br />
      ><br />
      > //Setting options for a secure SSL based xmlrpc server<br />
      ><br />
      > curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);<br />
      ><br />
      > curl_setopt($req, CURLOPT_SSL_VERIFYHOST, 2);<br />
      ><br />
      > curl_setopt( $req, CURLOPT_CUSTOMREQUEST, 'POST' );<br />
      ><br />
      > curl_setopt($req, CURLOPT_RETURNTRANSFER, 1 );<br />
      ><br />
      > curl_setopt($req, CURLOPT_HTTPHEADER, $headers );<br />
      ><br />
      > curl_setopt( $req, CURLOPT_POSTFIELDS, $request );<br />
      ><br />
      > //Finally run<br />
      ><br />
      > $response = curl_exec($req);<br />
      ><br />
      > //Close the cURL connection<br />
      ><br />
      > curl_close($req);<br />
      ><br />
      > //Decoding the response to be displayed<br />
      ><br />
      > var_dump($response);<br />
      ><br />
      ><br />
      ><br />
      > On 14 May 2010, at 15:51, eric@eamann.com wrote:<br />
      ><br />
      > > You can define your own XML-RPC methods and the functions that handle those method calls.  That's what I meant by the handler function.  For example, I use XML-RPC in all my plug-ins to report back installation progress and errors - each plug-in makes an XML-RPC call to a custom handler (method) on my server.<br />
      > > <br />
      > > Basically, you can define your own version of wp.getComments (maybe wpCustom.getComments) that focuses on MU blogs in whatever way you choose (identifying one blog by blog ID or getting information universally).<br />
      > > <br />
      > > On May 14, 2010 at 2:42 PM Luke Mackenzie <luke@lukem.co.uk> wrote:<br />
      > ><br />
      > > > Could you expand on what you mean by the handler function?<br />
      > > ><br />
      > > > I'm trying this call as an example:<br />
      > > ><br />
      > > > http://codex.wordpress.org/XML-RPC/wp.getComments<br />
      > > ><br />
      > > > Altering the blog_id has no effect on the comments returned. I have read elsewhere that the blog_id parameter is ignored. Is that still the case?<br />
      > > ><br />
      > > > An alternative would be to use different endpoints per blog as I believe these are separate in MU?<br />
      > > ><br />
      > > ><br />
      > > > Thanks again,<br />
      > > ><br />
      > > > Luke.<br />
      > > ><br />
      > > ><br />
      > > > On 14 May 2010, at 14:26, Eric Mann wrote:<br />
      > > ><br />
      > > > > Luke,<br />
      > > > ><br />
      > > > > I've worked with WordPress' XMLRPC system before (using a WP-Hive<br />
      > > > > installation with multiple separate blogs similar to a WPMU set-up).  The<br />
      > > > > new approach you're using is definitely simpler and easier to implement (I<br />
      > > > > tried the 5ubliminal one as well the first time).<br />
      > > > ><br />
      > > > > Whether or not you can distinguish between separate blogs in a MU<br />
      > > > > installation depends entirely on how you build your handler function.  You<br />
      > > > > can build it to distinguish the separate blogs, to only function on specific<br />
      > > > > blogs, or to treat the entire system as a single WordPress site.  It's all<br />
      > > > > up to you.<br />
      > > > ><br />
      > > > > Yes, you can retrieve and post to custom fields.<br />
      > > > ><br />
      > > > > Absolutely writing a plug-in is the way to go.  The only other options are<br />
      > > > > to change core files (BAD idea) or to build it into your theme, in which<br />
      > > > > case it could ONLY be used on MU sites using that theme.  Build it as a<br />
      > > > > site-wide MU plug-in that can be controlled on a site-by-site basis by the<br />
      > > > > global admin.<br />
      > > > ><br />
      > > > > ~Eric<br />
      > > > ><br />
      > > > > Eric Mann<br />
      > > > > www.eamann.com<br />
      > > > ><br />
      > > > ><br />
      > > > > -----Original Message-----<br />
      > > > > From: wp-xmlrpc-bounces@lists.automattic.com<br />
      > > > > [mailto:wp-xmlrpc-bounces@lists.automattic.com] On Behalf Of Luke Mackenzie<br />
      > > > > Sent: Friday, May 14, 2010 5:52 AM<br />
      > > > > To: wp-xmlrpc@lists.automattic.com<br />
      > > > > Subject: [wp-xmlrpc] XMLRPC for Wordpress Mu<br />
      > > > ><br />
      > > > > Hi,<br />
      > > > ><br />
      > > > > I have been tasked with creating an API for retrieving and adding content to<br />
      > > > > Wordpress from a flash application and legacy CMS (non-PHP). My plan is to<br />
      > > > > utilise the existing default xmlrpc endpoint and add any additional<br />
      > > > > functionality by creating a plugin which hooks into xmlrpc_methods.<br />
      > > > ><br />
      > > > > A previous attempt had been made by another developer based on the following<br />
      > > > > code:<br />
      > > > ><br />
      > > > > http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/<br />
      > > > ><br />
      > > > > This code looks unwieldy and poorly documented to me and my preference would<br />
      > > > > be to use this approach:<br />
      > > > ><br />
      > > > > http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/<br />
      > > > ><br />
      > > > > I would be grateful if anyone with experience in this area could confirm<br />
      > > > > that:<br />
      > > > ><br />
      > > > > - I will be able to distinguish between separate blogs in an MU installation<br />
      > > > > when both retrieving and posting data via XMLRPC<br />
      > > > > - I will be able to retrieve and post to custom fields<br />
      > > > > - writing a plugin is the way to go.<br />
      > > > ><br />
      > > > > We do not have the option of using Wordpress 3 as it is still in Beta and we<br />
      > > > > are under time pressure.<br />
      > > > ><br />
      > > > > I would greatly appreciate appreciate any input / advice.<br />
      > > > ><br />
      > > > > Many thanks,<br />
      > > > ><br />
      > > > > Luke.<br />
      > > > ><br />
      > > > ><br />
      > > > > _______________________________________________<br />
      > > > > wp-xmlrpc mailing list<br />
      > > > > wp-xmlrpc@lists.automattic.com<br />
      > > > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
      > > > ><br />
      > > > > _______________________________________________<br />
      > > > > wp-xmlrpc mailing list<br />
      > > > > wp-xmlrpc@lists.automattic.com<br />
      > > > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
      > > ><br />
      > > > _______________________________________________<br />
      > > > wp-xmlrpc mailing list<br />
      > > > wp-xmlrpc@lists.automattic.com<br />
      > > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
      > > _______________________________________________<br />
      > > wp-xmlrpc mailing list<br />
      > > wp-xmlrpc@lists.automattic.com<br />
      > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br />
      ><br />
    </div>
  </body>
</html>