Every time I look through the beta of WordPress 3.1, I find something new. Today I found the WP_HTTP_IXR_Client. The IXR_Client was there in previous versions, but it didn’t use the WordPress HTTP API, and so it rarely worked for me. This wrapper/rework of it works like a charm. Some quick examples:

Testing the client to see if it can talk to another blog:

$client = new WP_HTTP_IXR_Client('http://example.com/xmlrpc.php');
$client->query('demo.sayHello');
echo $client->getResponse();

That will print “Hello!” if it succeeded.

Testing something with parameters, like adding two numbers:

$client = new WP_HTTP_IXR_Client('http://example.com/xmlrpc.php');
$client->query('demo.addTwoNumbers', 4, 5);
echo $client->getResponse();

That will produce an output of 9… Okay, let’s do something meaningful.

$client = new WP_HTTP_IXR_Client('http://example.com/xmlrpc.php');
$client->query('wp.getOptions', 0, 'username', 'password', 'software_version');
$response = $client->getResponse();
echo $response['software_version']['value'];

It returns what version of WordPress I’m running on that test site. In this case, that would be 3.1-beta2-17056.

Take a look through the class-wp-xmlrpc-server.php file for the various things you can do. Maybe you can think of some handy ways to make your blogs talk to each other. 🙂

Shortlink:

8 Comments

  1. The original IXR code uses fsockopen, that doesn’t work for you? That said, converting to the WP HTTP API is worth while. Picking up the proxy support alone would be reason enough.

  2. Otto Im curious, would this enable something like i.e. a single signup across multiple blogs across multiple servers across the web, would be a neat way to bring the blogging communities together without having to rely on third parties, i.e. facebook or twitter connect as a great deal of sites don’t enable either for one reason or another.

    Am I making sense?

    Jay

  3. It’s late and I’m tired from putting Christmas together, so forgive me if this is a stupid question.

    Is this different than the XML-RPC in previous versions? I wrote some code a few months ago for a client that scraped their old non-wp-compatible site, converted the data as necessary, and posted their content, including featured images.

    I’m probably missing the point of this all together

  4. […] se pustíte do propojení samostatných webů, tak doplňuji několik zajímavých odkazů (1, 2, 3), kde naleznete inspiraci… Příspěvek je starý 8 měsíců […]

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Need to post PHP code? Wrap it in [php] and [/php] tags.