1. Go to this page and download the library: Download sophivorus/easy-wiki library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sophivorus / easy-wiki example snippets
// Connect to a MediaWiki Action API endpoint
$api = new EasyWiki( 'https://en.wikipedia.org/w/api.php' );
// Read data immediately
$wikitext = $api->getWikitext( 'Science' );
// Be very careful not to publish your bot password by accident!!!
$api->login( 'Your bot username', 'Your bot password' );
// Get the wikitext of the page named 'Foo'
$api->getWikitext( 'Foo' );
// Get the HTML of the page named 'Foo'
$api->getHTML( 'Foo' );
// Get the categories of the page named 'Foo'
$api->getCategories( 'Foo' );
// Get the results as an associative array
$data = $api->query( [ 'titles' => 'Foo', 'prop' => 'info' ] );
// Magically extract the desired piece of data from the gazillion wrappers
$language = $api->find( 'pagelanguage', $query );
// If the result contains more than one relevant piece of data, you'll get an array of values instead
$data = $api->query( [ 'titles' => 'Foo|Bar|Baz', 'prop' => 'info' ] );
$languages = $api->find( 'pagelanguage', $data );
foreach ( $languages as $language ) {
echo $language;
}
// Create a page named 'Foo' with content 'Hello world!'
$api->create( 'Foo', 'Hello world!' );
// Replace the content of the page named 'Foo' with 'Bye!'
$api->edit( 'Foo', [ 'text' => 'Bye!' ] );
// Rename the page named 'Foo' to 'Bar'
$api->move( 'Foo', 'Bar' );
// Delete the page named 'Bar'
$api->delete( 'Bar' );
// Add a summary
$api->create( 'Foo', 'Hello world!', [ 'summary' => 'My first edit!' ] );
// Mark the edit as minor
$api->edit( 'Foo', 'Bye!', [ 'minor' => true ] );
// Don't leave a redirect behind and move all subpages too
$api->move( 'Foo', 'Bar', [ 'noredirect' => true, 'movesubpages' => true ] );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.