2017 © Pedro Peláez
 

library mediawiki-api

A MediaWiki API library

image

addwiki/mediawiki-api

A MediaWiki API library

  • Monday, May 21, 2018
  • by addshore
  • Repository
  • 7 Watchers
  • 22 Stars
  • 16,784 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 12 Forks
  • 0 Open issues
  • 13 Versions
  • 60 % Grown

The README.md

mediawiki-api

GitHub issue custom search in repo Latest Stable Version Download count, (*1)

Installation

Use composer to install the library and all its dependencies:, (*2)

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

Example Usage

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

// Create an authenticated API and services
$auth = new \Addwiki\Mediawiki\Api\Client\Auth\UserAndPassword( 'username', 'password' )
$api = new \Addwiki\Mediawiki\Api\Client\Action\ActionApi( 'http://localhost/w/api.php', $auth );
$services = new \Addwiki\Mediawiki\Api\MediawikiFactory( $api );

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

// Edit a page
$content = new \Addwiki\Mediawiki\DataModel\Content( 'New Text' );
$revision = new \Addwiki\Mediawiki\DataModel\Revision( $content, $page->getPageIdentifier() );
$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' )
);

// Create a new page
$newContent = new \Addwiki\Mediawiki\DataModel\Content( 'Hello World' );
$title = new \Addwiki\Mediawiki\DataModel\Title( 'New Page' );
$identifier = new \Addwiki\Mediawiki\DataModel\PageIdentifier( $title );
$revision = new \Addwiki\Mediawiki\DataModel\Revision( $newContent, $identifier );
$services->newRevisionSaver()->save( $revision );

// List all pages in a category
$pages = $services->newPageListGetter()->getPageListFromCategoryName( 'Category:Cat name' );

Running the integration tests

To run the integration tests, you need to have a running MediaWiki instance. The tests will create pages and categories without using a user account so it's best if you use a test instance. Furthermore you need to turn off rate limiting by adding the line, (*3)

$wgGroupPermissions['*']['noratelimit'] = true;, (*4)

to the LocalSettings.php of your MediaWiki., (*5)

By default, the tests will use the URL http://localhost/w/api.php as the API endpoint. If you have a different URL (e.g. http://localhost:8080/w/api.php), you need to configure the URL as an environment variable before running the tests. Example:, (*6)

export MEDIAWIKI_API_URL='http://localhost:8080/w/api.php'

Warning: Running the integration tests can take a long time to complete., (*7)

The Versions

08/03 2017
03/08 2016

0.6

0.6.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

07/09 2015

0.5.1

0.5.1.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

04/09 2015

0.5

0.5.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

13/01 2015

0.4

0.4.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

01/08 2014

dev-rethinkServices

dev-rethinkServices

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

24/06 2014

0.3

0.3.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

23/02 2014

0.2

0.2.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki

23/02 2014

0.1

0.1.0.0

A Mediawiki api lib

  Sources   Download

GPL-2.0+

The Requires

 

by Avatar addshore

mediawiki