<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks Eric - I was just using curl as a test as I am familiar with it. The requests in the live environment will actually be coming from a flash application but thanks for the heads-up on the IXR library.<div><br></div><div><br></div><div><div><div>On 14 May 2010, at 17:31, <a href="mailto:eric@eamann.com">eric@eamann.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">You're certainly going about this the hard way. Why not just use the IXR library already bundled with WordPress?</div><p style="margin: 0px;"> </p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><?php</div><p style="margin: 0px;"> </p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">include_once(ABSPATH . WPINC . '/class-IXR.php');<br>
<br>
$rpc = new IXR_Client( "<a href="http://wpmu.localhost/xmlrpc.php">http://wpmu.localhost/xmlrpc.php</a>" );<br>
$status = $rpc->query(<br>
"wp.getComments", // method name<br>
"2", // blog id<br>
"admin", // username<br>
"disney75", // password</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 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 );</div><p style="margin: 0px;"> </p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">?></div><p style="margin: 0px;"> </p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 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></div><div> <br class="webkit-block-placeholder"></div>
<div style="margin: 5px 0px 5px 0px; font-family: monospace;">
On May 14, 2010 at 3:57 PM Luke Mackenzie <<a href="mailto:luke@lukem.co.uk">luke@lukem.co.uk</a>> 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, <a href="mailto:eric@eamann.com">eric@eamann.com</a> 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 <<a href="mailto:luke@lukem.co.uk">luke@lukem.co.uk</a>> 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>
> > > <a href="http://codex.wordpress.org/XML-RPC/wp.getComments">http://codex.wordpress.org/XML-RPC/wp.getComments</a><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>
> > > > <a href="http://www.eamann.com">www.eamann.com</a><br>
> > > ><br>
> > > ><br>
> > > > -----Original Message-----<br>
> > > > From: <a href="mailto:wp-xmlrpc-bounces@lists.automattic.com">wp-xmlrpc-bounces@lists.automattic.com</a><br>
> > > > [mailto:wp-xmlrpc-bounces@lists.automattic.com] On Behalf Of Luke Mackenzie<br>
> > > > Sent: Friday, May 14, 2010 5:52 AM<br>
> > > > To: <a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><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>
> > > > <a href="http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/">http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/</a><br>
> > > ><br>
> > > > This code looks unwieldy and poorly documented to me and my preference would<br>
> > > > be to use this approach:<br>
> > > ><br>
> > > > <a href="http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/">http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/</a><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>
> > > > <a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><br>
> > > > <a href="http://lists.automattic.com/mailman/listinfo/wp-xmlrpc">http://lists.automattic.com/mailman/listinfo/wp-xmlrpc</a><br>
> > > ><br>
> > > > _______________________________________________<br>
> > > > wp-xmlrpc mailing list<br>
> > > > <a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><br>
> > > > <a href="http://lists.automattic.com/mailman/listinfo/wp-xmlrpc">http://lists.automattic.com/mailman/listinfo/wp-xmlrpc</a><br>
> > ><br>
> > > _______________________________________________<br>
> > > wp-xmlrpc mailing list<br>
> > > <a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><br>
> > > <a href="http://lists.automattic.com/mailman/listinfo/wp-xmlrpc">http://lists.automattic.com/mailman/listinfo/wp-xmlrpc</a><br>
> > _______________________________________________<br>
> > wp-xmlrpc mailing list<br>
> > <a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><br>
> > <a href="http://lists.automattic.com/mailman/listinfo/wp-xmlrpc">http://lists.automattic.com/mailman/listinfo/wp-xmlrpc</a><br>
><br>
</div>
</div>
_______________________________________________<br>wp-xmlrpc mailing list<br><a href="mailto:wp-xmlrpc@lists.automattic.com">wp-xmlrpc@lists.automattic.com</a><br>http://lists.automattic.com/mailman/listinfo/wp-xmlrpc<br></blockquote></div><br></div></body></html>