addwiki/mediawiki-api

A Mediawiki api lib

Installs: 1 591

Dependents: 1

Stars: 5

Watchers: 5

Forks: 4

Open Issues: 2

Language: PHP

0.4 2015-01-13 19:29 UTC

README

Build Status Code Coverage Scrutinizer Quality Score Dependency Status

On Packagist: Latest Stable Version Download count

Installation

Use composer to install the library and all its dependencies:

composer require "addwiki/mediawiki-api:~0.3.0"

Example Usage

// Load all the stuff
require_once( __DIR__ . '/vendor/autoload.php' );

// Log in to a wiki
$api = new \Mediawiki\Api\MediawikiApi( 'http://localhost/w/api.php' );
$api->login( new \Mediawiki\Api\ApiUser( 'username', 'password' ) );
$services = new \Mediawiki\Api\MediawikiFactory( $api );

// Get a page
$page = $services->newPageGetter()->getFromTitle( 'Foo' );

// Edit a page
$revision = $page->getRevisions()->getLatest();
$revision->getContent()->setText( 'NewText' );
$services->newRevisionSaver()->save( $revision );

// Move a page
$services->newPageMover()->move(
    $services->newPageGetter()->getFromTitle( 'FooBar' ),
    new Title( 'FooBar' )
);

// Delete a page
$services->newPageDeleter()->delete(
    $services->newPageGetter()->getFromTitle( 'DeleteMe!' ),
    array( 'reason' => 'Reason for Deletion' )
);