1

I'm trying to use the Perl module RPC::XML::Client to handle the XMLRPC API of Dokuwiki. In another SO post, the XMLRPC API of Dokuwiki was suggested as a way to programmatically post pages..

I'm not sure what I'm doing wrong, but I'm not able to log on using this code:

#!/bin/env perl
package PostWiki;

use 5.010;    # Require at least Perl version 5.10
use strict;   # Must declare all variables before using them
use warnings; # Emit helpful warnings
use autodie;  # Fatal exceptions for common unrecoverable errors (e.g. open)

use RPC::XML::Client;

my $client = RPC::XML::Client->new('http://example.com/wikiname/lib/exe/xmlrpc.php');
my $logged_on_ok = $client->send_request('dokuwiki.login','username','password');
my $res = $client->send_request('dokuwiki.getVersion');
print $res;

I get this error:

RPC::XML::Client::send_request: HTTP server error: Unauthorized

I log into the page manually using the same username and password, so that should not be the issue.

I have remoteuser set to the same username that I use to log onto the wiki to make manual edits. (For security purposes, this is not the same as the administrator user).

I also have securecookie unchecked, since anyone is free to browse the site, even though only a few can edit it. But it also didn't work when I had it checked.

I don't have access to the server itself except through the wiki, otherwise I could simply copy the files to the server.

4

1 回答 1

1

(Ideally I would add a comment, but I don't have enough reputation yet to do so.)

Dokuwiki's xmlrpc will returns a 401-Unauthorized if the remote user is unknown. (it would be a 403-Forbidden if the user is known but doesn't have enough permissions)

It can be the case in particular if your xmlrpc module doesn't deal with cookies since dokwiki.login relies on them

I don't know RPC::XML::Client, but a quick search didn't show that it deals naturally with cookies. You might want to make sure it's the case, or check how to handle them.

Alternatively, if you're not stuck with perl, you might wan to have a look at DokuJClient, an xmlrpc java client for Dokuwiki.

于 2013-05-26T08:20:53.880 回答