1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
#!/usr/bin/perl use warnings; use strict; use MediaWiki::API; my $mw = MediaWiki::API->new(); $mw->{config}->{api_url} = 'http://ma22-wiki-001/eblwiki/api.php'; # log in to the wiki $mw->login( { lgname => 'user', lgpassword => 'xxxxxx' } ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details}; # get a list of articles in category my $articles = $mw->list ( { action => 'query', list => 'categorymembers', cmtitle => 'Category:Perl', cmlimit => 'max' } ) || die $mw->{error}->{code} . ': ' . $mw->{error}->{details}; # and print the article titles foreach (@{$articles}) { print "$_->{title}\n"; }
QuoteC:\Perl-Tools\MediaWiki>perl wiki_auflisten.pl
2: Failed to decode JSON returned by http://ma22-wiki-001/eblwiki/api.php
Decoding Error:
malformed JSON string, neither tag, array, object, number, string or atom, at ch
aracter offset 0 (before "\x{feff}{"login":{"r...") at C:/strawberry/perl/site/l
ib/MediaWiki/API.pm line 400.
Returned Data:
´╗┐{"login":{"result":"NeedToken","token":"c81b0c8c82c4553e99e0ee4c0d752705","co
okieprefix":"eblwiki_eblw_","sessionid":"1fb9f785040716c3b4e62c59f0db8870"}} at
wiki_auflisten.pl line 11.
C:\Perl-Tools\MediaWiki>pause
Drücken Sie eine beliebige Taste . . .