Hi
I admit I'm not the sharpest perlprogrammer in the world, so I need some help here. I'm trying to automate some things and I want to use MediaWiki::API. My final goal is to write an exportscript that export all pages in some categories and then an importscript that import the xml-file on another wiki.
When I run the script below I get the following error: Use of uninitialized value in print at get_export.pl line 15.
But if I run it from my webbrowser I get the result: api.php?action=query&generator=categories&titles=Page1 <?xml version="1.0" encoding="utf-8"?> <api> <query> <pages> <page pageid="5" ns="14" title="Category:Teologi" /> </pages> </query> </api>
The Script: use MediaWiki::API; binmode STDOUT, ':utf8';
my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://192.168.10.1/wiki3/api.php';
# log in to the wiki $mw->login( { lgname => 'WikiSysop', lgpassword => 'xxxxxx' } ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
if ( my $ref = $mw->api( { action => 'query', generator => 'categories', titles => 'Page1'} )) { print $ref->{query}->{pages}->{page}->{ns}; }
What is wrong with my script (or me)?
Kindly Regards Claes
2010/4/12 Claes Lindvall classe@ekvagen.com:
But if I run it from my webbrowser I get the result:
api.php?action=query&generator=categories&titles=Page1
<?xml version="1.0" encoding="utf-8"?>
<api> <query> <pages> <page pageid="5" ns="14" title="Category:Teologi" /> </pages> </query> </api>
The Script: use MediaWiki::API; binmode STDOUT, ':utf8'; my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://192.168.10.1/wiki3/api.php'; # log in to the wiki $mw->login( { lgname => 'WikiSysop', lgpassword => 'xxxxxx' } ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details};
if ( my $ref = $mw->api( { action => 'query', generator => 'categories', titles => 'Page1'} )) { print $ref->{query}->{pages}->{page}->{ns}; }
What is wrong with my script (or me)?
I'm not very familiar with MediaWiki::API, but I think it may need a certain format= parameter to work; the result you posted seems to result from not passing a format= parameter.
Roan Kattouw (Catrope)
mediawiki-api@lists.wikimedia.org