EasyWiki
in package
The EasyWiki library is composed of this single class
Table of Contents
- __construct() : self
- Initialize EasyWiki
- append() : array<string|int, mixed>
- Append wikitext to a page
- create() : mixed
- Create a page
- delete() : array<string|int, mixed>
- Do a POST request to the delete module
- edit() : array<string|int, mixed>
- Do a POST request to the edit module
- find() : mixed
- Recursively search for a key in an array and return its value
- get() : array<string|int, mixed>
- Do a GET request to the API
- getCategories() : array<string|int, mixed>|null
- Get the categories of a page
- getHTML() : string
- Get the HTML of a page
- getInfo() : array<string|int, mixed>|string
- Get the basic info of a page
- getSiteInfo() : array<string|int, mixed>|string
- Get the general info of the site
- getToken() : string
- Get a token for write actions
- getWikitext() : string
- Get the wikitext of a page
- login() : array<string|int, mixed>
- Do a POST request to the login module
- logout() : mixed
- Do a POST request to the logout module
- move() : array<string|int, mixed>
- Do a POST request to the move module
- parse() : array<string|int, mixed>
- Do a GET request to the parse module
- post() : array<string|int, mixed>
- Do a POST request to the API
- prepend() : array<string|int, mixed>
- Prepend wikitext to a page
- query() : array<string|int, mixed>
- Do a GET request to the query module
Methods
__construct()
Initialize EasyWiki
public
__construct([string $api = '' ][, string $user = '' ][, string $pass = '' ]) : self
Parameters
- $api : string = ''
-
URL of the MediaWiki API endpoint to use
- $user : string = ''
-
Bot username to log in with
- $pass : string = ''
-
Bot password to log in with
Return values
self —EasyWiki instance
append()
Append wikitext to a page
public
append(string|int $page, string $text[, array<string|int, mixed> $params = [] ][, mixed $needle = '' ]) : array<string|int, mixed>
Parameters
- $page : string|int
-
Name or ID of the page to edit
- $text : string
-
Text to append
- $params : array<string|int, mixed> = []
-
Additional parameters for the edit module
- $needle : mixed = ''
Tags
Return values
array<string|int, mixed> —Edit module response
create()
Create a page
public
create(string $title, string $text[, array<string|int, mixed> $params = [] ][, mixed $needle = '' ]) : mixed
Parameters
- $title : string
- $text : string
-
Content of the new page
- $params : array<string|int, mixed> = []
-
Additional parameters for edit module
- $needle : mixed = ''
Tags
Return values
mixed —delete()
Do a POST request to the delete module
public
delete(string|int $page[, array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $page : string|int
-
Name or ID of the page to delete
- $params : array<string|int, mixed> = []
-
Additional parameters for delete module
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Reponse data
edit()
Do a POST request to the edit module
public
edit(string|int $page[, array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $page : string|int
-
Name or ID of the page to edit
- $params : array<string|int, mixed> = []
-
Additional params for the edit module
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Reponse data
find()
Recursively search for a key in an array and return its value
public
find(string $needle, array<string|int, mixed> $haystack) : mixed
Parameters
- $needle : string
-
Key to find
- $haystack : array<string|int, mixed>
-
Array where to search
Return values
mixed —Value of the needle or null if not found
get()
Do a GET request to the API
public
get([array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Parameters of the GET request
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Response data
getCategories()
Get the categories of a page
public
getCategories(string|int $page) : array<string|int, mixed>|null
Parameters
- $page : string|int
-
Name or ID of the page
Tags
Return values
array<string|int, mixed>|null —Page categories or null if the page has no categories or doesn't exist
getHTML()
Get the HTML of a page
public
getHTML(string|int $page[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $page : string|int
-
Page name or ID
- $params : array<string|int, mixed> = []
-
Additional parameters for parse module
Tags
Return values
string —HTML of the page
getInfo()
Get the basic info of a page
public
getInfo(string|int $page[, string $needle = '' ]) : array<string|int, mixed>|string
Parameters
- $page : string|int
-
Name or ID of the page
- $needle : string = ''
-
Key of the piece of info to get. Omit to get an array with all the info.
Tags
Return values
array<string|int, mixed>|string —Page info
getSiteInfo()
Get the general info of the site
public
getSiteInfo([string $needle = '' ]) : array<string|int, mixed>|string
Parameters
- $needle : string = ''
-
Key of the piece of info to get. Omit to get an array with all the info.
Tags
Return values
array<string|int, mixed>|string —Site info
getToken()
Get a token for write actions
public
getToken([string $type = 'csrf' ]) : string
Parameters
- $type : string = 'csrf'
-
Type of token to get
Tags
Return values
string —Token
getWikitext()
Get the wikitext of a page
public
getWikitext(string $page[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $page : string
-
Page name or ID
- $params : array<string|int, mixed> = []
-
Additional parameters for parse module
Tags
Return values
string —Wikitext of the page
login()
Do a POST request to the login module
public
login(string $user, string $pass) : array<string|int, mixed>
Parameters
- $user : string
-
Bot username
- $pass : string
-
Bot password
Return values
array<string|int, mixed> —Response data
logout()
Do a POST request to the logout module
public
logout() : mixed
Return values
mixed —move()
Do a POST request to the move module
public
move(string|int $from, string $to[, array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $from : string|int
-
Name or ID of the page to move
- $to : string
-
New page name
- $params : array<string|int, mixed> = []
-
Additional params for the move module
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Reponse data
parse()
Do a GET request to the parse module
public
parse([array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Additional params for the parse module
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Response data
post()
Do a POST request to the API
public
post([array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Parameters of the GET request
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Response data
prepend()
Prepend wikitext to a page
public
prepend(string|int $page, string $text[, array<string|int, mixed> $params = [] ][, mixed $needle = '' ]) : array<string|int, mixed>
Parameters
- $page : string|int
-
Name or ID of the page to edit
- $text : string
-
Text to prepend
- $params : array<string|int, mixed> = []
-
Additional parameters for edit module
- $needle : mixed = ''
Tags
Return values
array<string|int, mixed> —Edit module response
query()
Do a GET request to the query module
public
query([array<string|int, mixed> $params = [] ][, string $needle = '' ]) : array<string|int, mixed>
Parameters
- $params : array<string|int, mixed> = []
-
Additional params for the query module
- $needle : string = ''
-
Key of the data to extract from the response
Return values
array<string|int, mixed> —Aggregated response data