apiUrl = $apiUrl; $this->pageUrl = str_replace( 'api.php', 'index.php?title=Special:SpecialPages', $apiUrl ); $this->api = MediawikiApi::newFromApiEndpoint( $this->apiUrl ); } /** * Get the url of the api to test against, based on the MEDIAWIKI_API_URL environment variable. * @return string */ public function getApiUrl() { return $this->apiUrl; } /** * Get the url of a page on the wiki to test against, based on the api url. * @return string */ public function getPageUrl() { return $this->pageUrl; } /** * Get the MediawikiApi to test against * @return MediawikiApi */ public function getApi() { return $this->api; } /** * Save a wiki page. * @param string $title The title of the page. * @param string $content The complete page text to save. */ public function savePage( $title, $content ) { $params = [ 'title' => $title, 'text' => $content, 'md5' => md5( $content ), 'token' => $this->api->getToken(), ]; $this->api->postRequest( new SimpleRequest( 'edit', $params ) ); } }