Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aportela/mediawiki-wrapper
Custom php mediawiki api wrapper
https://github.com/aportela/mediawiki-wrapper
composer-package mediawiki mediawiki-api php php8 wikidata wikidata-api wikipedia wikipedia-api
Last synced: 9 days ago
JSON representation
Custom php mediawiki api wrapper
- Host: GitHub
- URL: https://github.com/aportela/mediawiki-wrapper
- Owner: aportela
- License: agpl-3.0
- Created: 2023-08-08T09:55:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-03T08:31:58.000Z (12 months ago)
- Last Synced: 2024-11-16T17:41:49.218Z (about 1 month ago)
- Topics: composer-package, mediawiki, mediawiki-api, php, php8, wikidata, wikidata-api, wikipedia, wikipedia-api
- Language: PHP
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mediawiki-wrapper
Custom mediawiki api wrapper
## Requirements
- mininum php version 8.x
- curl extension must be enabled (aportela/httprequest-wrapper)## Limitations
At this time only Wikipedia & Wikidata english pages are supported, also files
## Install (composer) dependencies:
```
composer require aportela/mediawiki-wrapper
```## Code example:
```
setItem("Q319");
$title = $i->getWikipediaTitle(\aportela\MediaWikiWrapper\Language::ENGLISH);// get wikipedia title page from wikidata url
$i = new \aportela\MediaWikiWrapper\Wikidata\Item($logger, \aportela\MediaWikiWrapper\APIType::REST);
$i->setURL("https://www.wikidata.org/wiki/Q319");
$title = $i->getWikipediaTitle(\aportela\MediaWikiWrapper\Language::ENGLISH);// get wikipedia html page from wikipedia title
$p = new \aportela\MediaWikiWrapper\Wikipedia\Page($logger, \aportela\MediaWikiWrapper\APIType::REST);
$p->setTitle($title);
$html = $p->getHTML();// get wikipedia html page from wikipedia url
$p = new \aportela\MediaWikiWrapper\Wikipedia\Page($logger, \aportela\MediaWikiWrapper\APIType::REST);
$p->setURL("https://en.wikipedia.org/wiki/Jupiter");
$html = $p->getHTML();// get file URL from title
$f = new \aportela\MediaWikiWrapper\Wikipedia\File($logger, \aportela\MediaWikiWrapper\APIType::REST);
$f->setTitle("Commons-logo.svg");
if ($f->get()) {
$preferredURL = $f->getURL(\aportela\MediaWikiWrapper\FileInformationType::PREFERRED);
$originalURL = $f->getURL(\aportela\MediaWikiWrapper\FileInformationType::ORIGINAL);
$thumbnailURL = $f->getURL(\aportela\MediaWikiWrapper\FileInformationType::THUMBNAIL);
}
```![PHP Composer](https://github.com/aportela/mediawiki-wrapper/actions/workflows/php.yml/badge.svg)