Jump to content

Manual:Chris G's botclasses/UploadBot.php

From mediawiki.org
<?php
/*
 * uploadBot.php
 * This bot uploads a file.
/*

/* Set up classes. */
include( '/home/nathan/Chris-G-botclasses/botclasses.php' );
$wiki      = new wikipedia;
$wiki->url = "http://localhost/test117/w/api.php";
$wiki->setUserAgent( 'User-Agent: FooBot (http://mediawiki.org/wiki/User:FooBot)' );

/* All the login stuff. */
$user = 'Natebot';
$pass = 'password';
$wiki->login( $user, $pass );

/* Test edit. */
$page = 'Foo.jpg';
$file = '/home/nathan/samples/Sunflower3-2012.jpg';
$summary = 'This is a sample upload.';
var_dump( $wiki->upload( $page, '/home/nathan/samples/Sunflower3-2012.jpg', $summary ) );