Skip to content

Instantly share code, notes, and snippets.

@dbolser
Created September 30, 2011 13:12
Show Gist options
  • Save dbolser/1253701 to your computer and use it in GitHub Desktop.
Save dbolser/1253701 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use Encode;
use MediaWiki::API; # our $VERSION = "0.37";
use Digest::MD5 qw(md5_hex);
my $mw = MediaWiki::API->new();
## Configure the API URL
$mw->{config}->{api_url} =
'http://.../api.php';
## Set a default error function
$mw->{config}->{on_error} = sub
{ print "Error code: ". $mw->{error}->{code}. "\n";
print $mw->{error}->{stacktrace}. "\n";
die;
};
## Login to the wiki
$mw->
login({
lgname => 'x',
lgpassword => 'y'
});
my $title = 'CLDB7154 - 293T';
my $page = $mw->get_page({ title => $title });
#print Dumper $page; exit;
print $page->{'*'}, "\n";
print Encode::is_utf8( $page->{'*'} ), "\n";
my $timestamp = $page->{timestamp};
my $md5_hex = md5_hex( $page->{'*'} );
$mw->
edit({
action => 'edit',
bot => '',
title => $title,
## To avoid edit conflicts...
basetimestamp => $timestamp,
text => $page->{'*'},
md5 => $md5_hex,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment