[wp-xmlrpc] XMLRPC for Wordpress Mu - blog_id parameter

Luke Mackenzie luke at lukem.co.uk
Fri May 14 15:57:33 UTC 2010


Thanks again,

Can anyone confirm if the blog_id parameter should work in the wp.getComments call? This is what I'm doing to test it:

I've tried passing the blog ID as both a string and an integer. Wordpress MU version is 2.9.2

I always get the comments from the default blog.

<?php

error_reporting(E_ALL);

$method= 'wp.getComments';

$username = 'admin';

$password = 'disney75';


$blog_id = 2;

$params = array($blog_id, $username, $password, array('status'=>'approve'));

$service_url = 'http://wpmu.localhost/xmlrpc.php';

//Using the XML-RPC extension to format the XML package

$request = xmlrpc_encode_request($method, $params);

//var_dump($request);

$req = curl_init($service_url);

// Using the cURL extension to send it off,  first creating a custom header block

$headers = array();

array_push($headers,"Content-Type: text/xml");

array_push($headers,"Content-Length: ".strlen($request));

array_push($headers,"\r\n");

//URL to post to

curl_setopt($req, CURLOPT_URL, $service_url);

//Setting options for a secure SSL based xmlrpc server

curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($req, CURLOPT_SSL_VERIFYHOST, 2);

curl_setopt( $req, CURLOPT_CUSTOMREQUEST, 'POST' );

curl_setopt($req, CURLOPT_RETURNTRANSFER, 1 );

curl_setopt($req, CURLOPT_HTTPHEADER, $headers );

curl_setopt( $req, CURLOPT_POSTFIELDS, $request );

//Finally run

$response = curl_exec($req);

//Close the cURL connection

curl_close($req);

//Decoding the response to be displayed

var_dump($response);



On 14 May 2010, at 15:51, eric at eamann.com wrote:

> 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.
>  
> 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).
>  
> On May 14, 2010 at 2:42 PM Luke Mackenzie <luke at lukem.co.uk> wrote:
> 
> > Could you expand on what you mean by the handler function?
> >
> > I'm trying this call as an example:
> >
> > http://codex.wordpress.org/XML-RPC/wp.getComments
> >
> > 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?
> >
> > An alternative would be to use different endpoints per blog as I believe these are separate in MU?
> >
> >
> > Thanks again,
> >
> > Luke.
> >
> >
> > On 14 May 2010, at 14:26, Eric Mann wrote:
> >
> > > Luke,
> > >
> > > I've worked with WordPress' XMLRPC system before (using a WP-Hive
> > > installation with multiple separate blogs similar to a WPMU set-up).  The
> > > new approach you're using is definitely simpler and easier to implement (I
> > > tried the 5ubliminal one as well the first time).
> > >
> > > Whether or not you can distinguish between separate blogs in a MU
> > > installation depends entirely on how you build your handler function.  You
> > > can build it to distinguish the separate blogs, to only function on specific
> > > blogs, or to treat the entire system as a single WordPress site.  It's all
> > > up to you.
> > >
> > > Yes, you can retrieve and post to custom fields.
> > >
> > > Absolutely writing a plug-in is the way to go.  The only other options are
> > > to change core files (BAD idea) or to build it into your theme, in which
> > > case it could ONLY be used on MU sites using that theme.  Build it as a
> > > site-wide MU plug-in that can be controlled on a site-by-site basis by the
> > > global admin.
> > >
> > > ~Eric
> > >
> > > Eric Mann
> > > www.eamann.com
> > >
> > >
> > > -----Original Message-----
> > > From: wp-xmlrpc-bounces at lists.automattic.com
> > > [mailto:wp-xmlrpc-bounces at lists.automattic.com] On Behalf Of Luke Mackenzie
> > > Sent: Friday, May 14, 2010 5:52 AM
> > > To: wp-xmlrpc at lists.automattic.com
> > > Subject: [wp-xmlrpc] XMLRPC for Wordpress Mu
> > >
> > > Hi,
> > >
> > > I have been tasked with creating an API for retrieving and adding content to
> > > Wordpress from a flash application and legacy CMS (non-PHP). My plan is to
> > > utilise the existing default xmlrpc endpoint and add any additional
> > > functionality by creating a plugin which hooks into xmlrpc_methods.
> > >
> > > A previous attempt had been made by another developer based on the following
> > > code:
> > >
> > > http://blog.5ubliminal.com/posts/remote-control-wordpress-blog-xmlrpc-api/
> > >
> > > This code looks unwieldy and poorly documented to me and my preference would
> > > be to use this approach:
> > >
> > > http://kovshenin.com/archives/custom-xml-rpc-methods-in-wordpress/
> > >
> > > I would be grateful if anyone with experience in this area could confirm
> > > that:
> > >
> > > - I will be able to distinguish between separate blogs in an MU installation
> > > when both retrieving and posting data via XMLRPC
> > > - I will be able to retrieve and post to custom fields
> > > - writing a plugin is the way to go.
> > >
> > > We do not have the option of using Wordpress 3 as it is still in Beta and we
> > > are under time pressure.
> > >
> > > I would greatly appreciate appreciate any input / advice.
> > >
> > > Many thanks,
> > >
> > > Luke.
> > >
> > >
> > > _______________________________________________
> > > wp-xmlrpc mailing list
> > > wp-xmlrpc at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
> > >
> > > _______________________________________________
> > > wp-xmlrpc mailing list
> > > wp-xmlrpc at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
> >
> > _______________________________________________
> > wp-xmlrpc mailing list
> > wp-xmlrpc at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-xmlrpc
> _______________________________________________
> wp-xmlrpc mailing list
> wp-xmlrpc at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-xmlrpc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.automattic.com/pipermail/wp-xmlrpc/attachments/20100514/14a21dd2/attachment.htm>


More information about the wp-xmlrpc mailing list