addwiki / mediawiki-api-base
Simple MediaWiki API library
3.1.0
2024-10-15 20:46 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ~6.3||~7.0
- guzzlehttp/promises: ~1.0
- mediawiki/oauthclient: ^2.1
- psr/log: ~3.0
Requires (Dev)
Suggests
- ext-dom: Needed if you want to discover APIs using only page URLs
- ext-simplexml: Needed if you want to discover APIs using only page URLs
README
This library provides basic access to the MediaWiki Action API. This library features simple methods allowing you to login, logout and do both GET and POST requests. This library should work with most if not all MediaWiki versions due to its simplicity.
You can find the full documentation at https://addwiki.github.io/mediawiki-api-base/
Example
A quick example can be found below:
use \Addwiki\Mediawiki\Api\Client\Auth\UserAndPassword; use \Addwiki\Mediawiki\Api\Client\Action\MediawikiApi; $auth = new UserAndPassword( 'username', 'password' ); $api = MediawikiApi::newFromPage( 'https://en.wikipedia.org/wiki/Berlin', $auth ); $purgeRequest = FluentRequest::factory()->setAction( 'purge' )->setParam( 'titles', 'Berlin' ); $api->postRequest( $purgeRequest );
Integration tests
Run the MediaWiki test site:
docker compose -f docker-compose-ci.yml up -d
Run the tests:
composer phpunit-integration
Destroy the site that was used for testing:
docker compose -f docker-compose-ci.yml down --volumes