Page 1 of 1

XML_RPC blogging via external PHP Script

Posted: Wed Jan 31, 2007 8:20 pm
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.

Re: XML_RPC blogging via external PHP Script

Posted: Thu Feb 01, 2007 11:00 am
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

good class - but how to create new categories

Posted: Sat Feb 03, 2007 10:21 pm
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

Posted: Mon Feb 05, 2007 9:47 pm
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.