On Thu, Jul 23, 2009 at 08:56:59PM -0400, Dan Collins wrote:
Hey Mike, and welcome to the wonderful world of the MediaWiki API!
You are correct, that should work for you. Make sure that $page really
contains the article name you want to save to, and if you're still
having problems, please post the output of the program if you insert
use Data::Dumper; print "$wikiaddurl\n"; print Dumper(\%post);
or equivalent, right before you actually make the post request,
removing the edittoken for security reasons, that way you and I can
see what you are actually sending to the server.
HOWEVER, there is an easier way. Rather than using the API directly,
there are a number of preexisting perl modules which allow you to
easily interface with any MediaWiki wiki. Use CPAN to look up
MediaWiki::Bot, which is a complete class, providing you with a login
function, an edit function, and many more. If you need any help with
that module, or would like to see an example script, you can contact
me directly.
Hope that helps!
ST47,
Thanks for getting back to me. I've been doing some major debugging
today. I have setup a test wiki since I want to test the code before
decimating a live wiki, so I decided I'd just upgrade to the latest
code, in case it was a problem in that version. This didn't resolve the
problem. I setup a new MediaWiki install from scratch on another server
and this time it worked. This narrowed the problem down to either the
DB or the config file. After a diff of the config file and some
experimenting, it came down to the setting of $wgArticlePath.
I have clean URLs configured and so have it set to $wgArticlePath =
'/$1'; This torpedoes the API code. If I comment it out, my code works
as expected, uncomment it and I end up with the data written to Api.php
again.
This appears to be the symptom. I haven't been able to identify the
cause yet. I've done a quick Google and there does appear to be some
stories of the API code causing some agro with paths. Namely this:
https://bugzilla.redhat.com/show_bug.cgi?id=484855
I need to do a little more digging into the actual cause though.
I don't know if you have any ideas?
Mike.