Subject: | Cannot get edit to work with MW 1.13 |
Date: | Sun, 14 Sep 2008 22:13:09 -0500 |
To: | bug-MediaWiki-API [...] rt.cpan.org |
From: | "David A. Bright" <BrightD [...] acm.org> |
I've got an installation of MW 1.13 (actually, 1.13.1) and I have
tried to use the MediaWiki API module to edit pages with no luck. I
can login and get pages without a problem, but if I try to use the
edit method, I get this:
malformed JSON string, neither array, object, number, string or atom,
at character offset 0 ["<br />\n<b>Fatal err..."] at /Library/Perl/
5.8.8/MediaWiki/API.pm line 225.
If I try with the api method, I get this:
3: badtoken: Invalid token at /Users/david/bin/MW-UpdatePage.pl line 76.
My code to get the edit token is:
# Get edit token
my $token = $mw->api( {
action => 'query',
prop => 'info|revisions',
intoken => 'edit',
titles => $pageTitle } )
|| die $mw->{error}->{code} . ': ' . $mw->{error}-
Show quoted text
>{details};
$token = $page->{'query'}->{'pages'}->{'1'}->{'edittoken'};
My edit() call looks like:
$mw->edit( {
action => 'edit',
bot => 1,
basetimestamp => $page->{'timestamp'},
token => $page->{'query'}->{'pages'}->{'1'}-
Show quoted text >{'edittoken'},
title => $pageTitle,
text => $newPageContents } )
|| die $mw->{error}->{code} . ': ' . $mw->{error}-
Show quoted text >{details};
And my api() call looks like:
$mw->api( {
action => 'edit',
bot => 1,
basetimestamp => $page->{'timestamp'},
token => $page->{'query'}->{'pages'}->{'1'}-
Show quoted text >{'edittoken'},
title => $pageTitle,
summary => "Automated update",
text => $newPageContents } )
|| die $mw->{error}->{code} . ': ' . $mw->{error}-
Show quoted text >{details};
I don't know if this is a bug in MW, MediaWiki::API, or if I am just
failing to understand how to use the API.
I'm running on Mac OS X 10.5.4, perl 5.8.8
Thanks.