Skip to content

KaiNissen/mediawiki-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mediawiki-api

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
$deleteOptions = new DeleteOptions();
$deleteOptions->setReason( 'Reason for Deletion' );
$services->newPageDeleter()->delete(
	$services->newPageGetter()->getFromTitle( 'DeleteMe!' ),
	$deleteOptions
);

About

Library for interacting with the mediawiki Api

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%