Skip to content

[MediaWiki] Advanced usages

Chen edited this page Nov 9, 2017 · 5 revisions

Private Wikis

Private wikis are those wikis where anonymous users have no read access. This can cause problem for ordinary login procedure, because the client can virtually invoke nothing other than action=login. To address the issue, you can use the alternative constructor signature to login to the wiki site before performing any other querying requests

public WikiSite(
	IWikiClient wikiClient,
	SiteOptions options,
	string userName,
	string password
)

As have mentioned in Getting Started page, you need to wait for the initialization to complete using await wikiSite.Initialization, before proceeding with any other operations. If the login failed, you will receive the exception via Initialization task.

Miscellaneous API

You can get/set/persist cookies with WikiClient.CookieContainer property.

The following APIs have also been taken or partially taken into the library

  • opensearch: See WikiSite.OpenSearch.
  • parse: See WikiSite.ParsePageAsync, WikiSite.ParseRevisionAsync, and WikiSite.ParseContentAsync. There's also a demo in WpfTestApplication1.

You can search for a valid MediaWiki entry point with WikiSite.SearchApiEndpointAsync, given the URL of the website or the URL of a page on it. See UnitTestProject1.SiteTests.SearchApiEndpointTest for example.

Behaviors

The following behavior has been implemented

  • Request timeout and retry (WikiClient)
  • Throttle before edit/move/delete (WikiSite.Throttler)

The following behavior has yet to be implemented

  • Detect {{inuse}}
  • Detect {{bots}}, {{nobots}}

Issuing custom JSON request to MediaWiki endpoint

  • You can use WikiSite.GetJsonAsync to send custom JSON request. (Note: I'm planning to rename the method to WikiSite.InvokeMediaWikiApiAsync)