diff --git a/README.md b/README.md index a02101f..2fdbca4 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,70 @@ # boz-mw This is another MediaWiki API handler in PHP. ## Tools See [the tools](./tools/README.md). ## API showcase -Here some usage examples: +Here some usage examples. + +### Basic API query ```php fetch( [ - 'action' => 'query', - 'prop' => 'info', - 'titles' => [ - 'Pagina principale' - ] -] ); +// load it.wiki +$wiki = \wm\WikipediaIt::instance(); + +$response = + $wiki->fetch( [ + 'action' => 'query', + 'prop' => 'info', + 'titles' => [ + 'Pagina principale' + ] + ] ); + print_r( $response ); +``` + +### API query with continuation + + +``` +$wiki = \wm\WikipediaIt::instance(); + +$queries = + $wiki->createQuery( [ + 'action' => 'query', + 'list' => 'categorymembers', + 'cmtitle' => 'Categoria:Software con licenza GNU GPL', + ] ); -echo "Simple Italian Wikipedia API query with continuation support:\n"; -$queries = \wm\WikipediaIt::instance()->createQuery( [ - 'action' => 'query', - 'list' => 'categorymembers', - 'cmtitle' => 'Categoria:Software con licenza GNU GPL', -] ); foreach( $queries as $query ) { print_r( $query ); } +``` + +### Edit API query -echo "Simple POST request:\n"; -\mw\API::$DEFAULT_USERNAME = 'My username'; -\mw\API::$DEFAULT_PASSWORD = 'My bot password'; -$w = \wm\WikipediaIt::instance()->login(); -$response = $w->edit( [ +``` +$wiki = \wm\WikipediaIt::instance(); + +$user = ''; +$password = ''; +$wiki->login( $user, $password ); + +$w->edit( [ 'title' => 'Special:Nothing', 'text' => 'My wikitext', 'summary' => 'My edit summary', ] ); -print_r( $response ); ``` ## Known usage * [ItalianWikipediaDeletionBot](https://github.com/valerio-bozzolan/ItalianWikipediaDeletionBot) * [wiki-users-leaflet](https://github.com/valerio-bozzolan/wiki-users-leaflet/) hosted at [WMF Labs](https://tools.wmflabs.org/it-wiki-users-leaflet/)