XML_RPC blogging via external PHP Script

Creating and modifying plugins.
Post Reply
tirili
Posts: 2
Joined: Wed Jan 31, 2007 8:13 pm

XML_RPC blogging via external PHP Script

Post by tirili »

I recently set up s9y-1.0.4 with the xml_rpc interface.
But I could not find any documentation how to remotely
create new categories or posts.

Even with

Code: Select all

require_once 'XML/RPC.php';

$xml_entries_vals[] = new XML_RPC_Value("tbaumann", "string");
$xml_entries_vals[] = new XML_RPC_Value("p@ssw0rd", "string");
$xml_entries_vals[] = new XML_RPC_Value("AAAAA", "string");
$xml_entries_vals[] = new XML_RPC_Value("BBBBB", "string");
$msg = new XML_RPC_Message('blogger.getUserInfo', $xml_entries_vals);

$cli = new XML_RPC_Client('/serendipity_xmlrpc.php', 's9y.1-search.de');

$cli->setDebug(1);
$msg->createPayload();
$resp = $cli->send($msg);
if (!$resp) {
    echo 'Communication error: ' . $cli->errstr;
    exit;
}

if (!$resp->faultCode()) {
    $val = $resp->value();
    $data = XML_RPC_decode($val);
    echo $data[0]['name'] . ' is at version ' . $data[0]['version'];
} else {
    /*
     * Display problems that have been gracefully cought and
     * reported by the xmlrpc.php script
     */
    echo 'Fault Code: ' . $resp->faultCode() . "\n";
    echo 'Fault Reason: ' . $resp->faultString() . "\n";
}
I get an authentication failed error.

When I log in normally to s9y with above username and password, I can login.

Can sb. help me ?

I just want to send an XML with CDATA containing the new Post and the
categories.

How can I add/list categories ?
How can I add posts?

I think we have to set up the variables
$xml_entries_vals[] correctly.

Thanks for any reply!

Thomas.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: XML_RPC blogging via external PHP Script

Post by garvinhicking »

Hi!

Which authentication error message do you get specifically?

Did you try to use a PHP tool like http://dentedreality.com.au/bloggerapi/ which offers you a PHP API to access blogs supporting the Blogger or MT API?

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
tirili
Posts: 2
Joined: Wed Jan 31, 2007 8:13 pm

good class - but how to create new categories

Post by tirili »

Thanks for the link. But it's a pity that there are no examples how to code by yourself.

Another Question:

How can I create new categories via xml_rpc ?

Thanks in advance!

- tom
judebert
Regular
Posts: 2478
Joined: Sat Oct 15, 2005 6:57 am
Location: Orlando, FL
Contact:

Post by judebert »

The XML-RPC API doesn't support creating new categories (neither Blogger nor MT, which are supported by Serendipity).

Here's a SourceForge page including example code in C for an XML-RPC client. The Wikipedia page has example XML, including parameters. So does the XML-RPC spec.

For more information about how we use the Blogger and Metaweblog APIs, check out our serendipity_event_xmlrpc plugin.

Looking more closely at your post (about time, duh), I see you're using the same PEAR classes we do. However, when I check the xmlrpc plugin, I see that it's using params[1] for username and params[2] for password (in blogger_getUserInfo(), which is associated to blogger.getUserInfo). Your example is setting params[0] to username, and params[1] to password. According to the documentation page, params[0] is supposed to be a unique key for your application.

The extra parameters will probably be ignored, but I'd take them off just to be safe.
Judebert
---
Website | Wishlist | PayPal
Post Reply