attus/mediawiki-api

A basic PHP MediaWiki API

2.1.0 2021-04-12 17:38 UTC

This package is auto-updated.

Last update: 2024-04-25 22:40:51 UTC


README

A basic PHP MediaWiki API to get pages and files

Get page content or URL:

$api = new Api('https://de.wikipedia.org');
$page = $api->getPage('Geschichte der Kölner Straßenbahn');
$content = $page->getContent();
$url = $page->getUrl();

Get image user and page url:

$api = new Api('https://de.wikipedia.org');
$image = $api->getImage('File:KVB4076_Severinsbruecke.jpg');
$pageUrl = $image->getPageUrl();
$user = $image->getImageUser();

Get image URL in a certain size:

$api = new Api('https://de.wikipedia.org');
$image = $api->getImage('File:KVB4076_Severinsbruecke.jpg');
$url = $image->getImageUrl(1920);

If the original image is smaller than the requested size, the URL of the original is returned.