*The same way you parse any other API response? Possibly something like my @extensions = map $_->{'ext'}, @{$x->{query}{fileextensions}} will do it.*
Thank you so much, it works now. The code is:
*sub get_file_extensions { mw_connect_maybe();
my $query = { action => 'query', meta => 'siteinfo', siprop => 'fileextensions' };
my $result = $mediawiki->api($query); my @file_extensions= map $_->{ext},@{$result->{query}->{fileextensions}};
return @file_extensions; } *
Best regards.
On Fri, Jun 1, 2012 at 6:31 PM, Brad Jorsch b-jorsch@alum.northwestern.eduwrote:
On Fri, Jun 01, 2012 at 11:36:35AM +0200, nguyenkim thuat wrote:
Yeah, but, how can i do it, i think of doing some thing like:
*sub get_file_extensions { mw_connect_maybe(); my $query = { action => 'query', meta => 'siteinfo', siprop => 'fileextensions' }; my $result = $mediawiki->api($query);
##### how to get the array of file extensions here?
}
The same way you parse any other API response? Possibly something like my @extensions = map $_->{'ext'}, @{$x->{query}{fileextensions}} will do it.
At worst, use Data::Dumper, print Dumper($result), and look at it to figure out what type of data structure it is.
Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api