C# Класс WikiFunctions.API.ApiEdit

This class edits MediaWiki sites using api.php
MediaWiki API manual: https://www.mediawiki.org/wiki/API Site prerequisites: MediaWiki 1.13+ with the following settings: * $wgEnableAPI = true; (enabled by default in DefaultSettings.php) * $wgEnableWriteAPI = true; * AssertEdit extension installed (https://www.mediawiki.org/wiki/Extension:Assert_Edit)
Наследование: IApiEdit
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
AdjustCookies void
ApiEdit System
CheckForErrors System.Xml.XmlDocument
CheckForErrors void
EnsureHtmlHeadersLoaded void
ExpandRelativeUrls string
customXertificateValidation bool

Открытые методы

Метод Описание
Abort ( ) : void

ApiEdit ( string url ) : System

Initializes a new instance of the ApiEdit class.

ApiEdit ( string url, bool usePHP5 ) : System

Initializes a new instance of the ApiEdit class.

Clone ( ) : IApiEdit
Delete ( string title, string reason ) : void
Delete ( string title, string reason, bool watch ) : void
ExpandTemplates ( string title, string text ) : string
HttpGet ( string url ) : string

Performs a HTTP request

Login ( string username, string password ) : void
Login ( string username, string password, string domain ) : void
Logout ( ) : void
Move ( string title, string newTitle, string reason ) : void
Move ( string title, string newTitle, string reason, bool moveTalk, bool noRedirect ) : void
Move ( string title, string newTitle, string reason, bool moveTalk, bool noRedirect, bool watch ) : void
Open ( string title ) : string

Opens the wiki page for editing

Open ( string title, bool resolveRedirects ) : string

Opens the wiki page for editing

ParseApi ( string>.Dictionary queryParameters ) : string
Preview ( string title, string text ) : string
Protect ( string title, string reason, TimeSpan expiry, string edit, string move ) : void
Protect ( string title, string reason, TimeSpan expiry, string edit, string move, bool cascade, bool watch ) : void
Protect ( string title, string reason, string expiry, string edit, string move ) : void
Protect ( string title, string reason, string expiry, string edit, string move, bool cascade, bool watch ) : void
QueryApi ( string queryParameters ) : string
QueryApiJson ( string queryParameters ) : string
RefreshUserInfo ( ) : void
Reset ( ) : void

Resets all internal variables, discarding edit tokens and so on, but does not logs off

Rollback ( string title, string user ) : void
Save ( string pageText, string summary, bool minor, WatchOptions watch ) : SaveInfo
Unwatch ( string title ) : void
Watch ( string title ) : void
WatchAction ( string title, bool unwatch ) : void

Защищенные методы

Метод Описание
AppendOptions ( string>.Dictionary request, ActionOptions options ) : void

BoolToParam ( bool value ) : string

BuildQuery ( string>.Dictionary request ) : string

BuildUrl ( string>.Dictionary request ) : string

BuildUrl ( string>.Dictionary request, ActionOptions options ) : string

CreateRequest ( string url ) : HttpWebRequest

CreateXmlReader ( string result ) : XmlReader
GetResponseString ( HttpWebRequest req ) : string

HttpGet ( string>.Dictionary request ) : string

Performs a HTTP request

HttpGet ( string>.Dictionary request, ActionOptions options ) : string

Performs a HTTP request

HttpPost ( string>.Dictionary get, string>.Dictionary post ) : string

HttpPost ( string>.Dictionary get, string>.Dictionary post, ActionOptions options ) : string

MD5 ( byte input ) : string

Computes the MD5 sum of a byte array

MD5 ( string input ) : string

Computes the MD5 sum of a string

NamedTitles ( string paramName ) : string

SetBasicAuthHeader ( WebRequest req, string userName, string userPassword ) : WebRequest

Source: http://blog.kowalczyk.info/article/Forcing-basic-http-authentication-for-HttpWebReq.html

Titles ( ) : string

WatchOptionsToParam ( WatchOptions watch ) : string

Приватные методы

Метод Описание
AdjustCookies ( ) : void

This is a hack required for some multilingual Wikimedia projects, where CentralAuth returns cookies with a redundant domain restriction.

ApiEdit ( ) : System

CheckForErrors ( string xml, string action ) : XmlDocument

Checks the XML returned by the server for error codes and throws an appropriate exception

CheckForErrors ( string xml ) : void

Checks the XML returned by the server for error codes and throws an appropriate exception

EnsureHtmlHeadersLoaded ( ) : void

Loads wiki's UI HTML and scrapes everything we need to make correct previews

ExpandRelativeUrls ( string html ) : string
customXertificateValidation ( object sender, X509Certificate cert, X509Chain chain, System error ) : bool

Описание методов

Abort() публичный Метод

public Abort ( ) : void
Результат void

ApiEdit() публичный Метод

Initializes a new instance of the ApiEdit class.
public ApiEdit ( string url ) : System
url string Path to scripts on server
Результат System

ApiEdit() публичный Метод

Initializes a new instance of the ApiEdit class.
public ApiEdit ( string url, bool usePHP5 ) : System
url string Path to scripts on server
usePHP5 bool Whether a .php5 extension is to be used
Результат System

AppendOptions() защищенный Метод

protected AppendOptions ( string>.Dictionary request, ActionOptions options ) : void
request string>.Dictionary
options ActionOptions
Результат void

BoolToParam() защищенный статический Метод

protected static BoolToParam ( bool value ) : string
value bool
Результат string

BuildQuery() защищенный статический Метод

protected static BuildQuery ( string>.Dictionary request ) : string
request string>.Dictionary
Результат string

BuildUrl() защищенный Метод

protected BuildUrl ( string>.Dictionary request ) : string
request string>.Dictionary
Результат string

BuildUrl() защищенный Метод

protected BuildUrl ( string>.Dictionary request, ActionOptions options ) : string
request string>.Dictionary
options ActionOptions
Результат string

Clone() публичный Метод

public Clone ( ) : IApiEdit
Результат IApiEdit

CreateRequest() защищенный Метод

protected CreateRequest ( string url ) : HttpWebRequest
url string
Результат System.Net.HttpWebRequest

CreateXmlReader() защищенный Метод

protected CreateXmlReader ( string result ) : XmlReader
result string
Результат XmlReader

Delete() публичный Метод

public Delete ( string title, string reason ) : void
title string
reason string
Результат void

Delete() публичный Метод

public Delete ( string title, string reason, bool watch ) : void
title string
reason string
watch bool
Результат void

ExpandTemplates() публичный Метод

public ExpandTemplates ( string title, string text ) : string
title string
text string
Результат string

GetResponseString() защищенный Метод

protected GetResponseString ( HttpWebRequest req ) : string
req System.Net.HttpWebRequest
Результат string

HttpGet() защищенный Метод

Performs a HTTP request
protected HttpGet ( string>.Dictionary request ) : string
request string>.Dictionary
Результат string

HttpGet() защищенный Метод

Performs a HTTP request
protected HttpGet ( string>.Dictionary request, ActionOptions options ) : string
request string>.Dictionary
options ActionOptions
Результат string

HttpGet() публичный Метод

Performs a HTTP request
public HttpGet ( string url ) : string
url string
Результат string

HttpPost() защищенный Метод

protected HttpPost ( string>.Dictionary get, string>.Dictionary post ) : string
get string>.Dictionary
post string>.Dictionary
Результат string

HttpPost() защищенный Метод

protected HttpPost ( string>.Dictionary get, string>.Dictionary post, ActionOptions options ) : string
get string>.Dictionary
post string>.Dictionary
options ActionOptions
Результат string

Login() публичный Метод

public Login ( string username, string password ) : void
username string
password string
Результат void

Login() публичный Метод

public Login ( string username, string password, string domain ) : void
username string
password string
domain string
Результат void

Logout() публичный Метод

public Logout ( ) : void
Результат void

MD5() защищенный статический Метод

Computes the MD5 sum of a byte array
protected static MD5 ( byte input ) : string
input byte Byte array to get MD5 sum of
Результат string

MD5() защищенный статический Метод

Computes the MD5 sum of a string
protected static MD5 ( string input ) : string
input string String to get MD5 sum of
Результат string

Move() публичный Метод

public Move ( string title, string newTitle, string reason ) : void
title string
newTitle string
reason string
Результат void

Move() публичный Метод

public Move ( string title, string newTitle, string reason, bool moveTalk, bool noRedirect ) : void
title string
newTitle string
reason string
moveTalk bool
noRedirect bool
Результат void

Move() публичный Метод

public Move ( string title, string newTitle, string reason, bool moveTalk, bool noRedirect, bool watch ) : void
title string
newTitle string
reason string
moveTalk bool
noRedirect bool
watch bool
Результат void

NamedTitles() защищенный статический Метод

protected static NamedTitles ( string paramName ) : string
paramName string
Результат string

Open() публичный Метод

Opens the wiki page for editing
public Open ( string title ) : string
title string The wiki page title
Результат string

Open() публичный Метод

Opens the wiki page for editing
public Open ( string title, bool resolveRedirects ) : string
title string The wiki page title
resolveRedirects bool
Результат string

ParseApi() публичный Метод

public ParseApi ( string>.Dictionary queryParameters ) : string
queryParameters string>.Dictionary
Результат string

Preview() публичный Метод

public Preview ( string title, string text ) : string
title string
text string
Результат string

Protect() публичный Метод

public Protect ( string title, string reason, TimeSpan expiry, string edit, string move ) : void
title string
reason string
expiry TimeSpan
edit string
move string
Результат void

Protect() публичный Метод

public Protect ( string title, string reason, TimeSpan expiry, string edit, string move, bool cascade, bool watch ) : void
title string
reason string
expiry TimeSpan
edit string
move string
cascade bool
watch bool
Результат void

Protect() публичный Метод

public Protect ( string title, string reason, string expiry, string edit, string move ) : void
title string
reason string
expiry string
edit string
move string
Результат void

Protect() публичный Метод

public Protect ( string title, string reason, string expiry, string edit, string move, bool cascade, bool watch ) : void
title string
reason string
expiry string
edit string
move string
cascade bool
watch bool
Результат void

QueryApi() публичный Метод

public QueryApi ( string queryParameters ) : string
queryParameters string
Результат string

QueryApiJson() публичный Метод

public QueryApiJson ( string queryParameters ) : string
queryParameters string
Результат string

RefreshUserInfo() публичный Метод

public RefreshUserInfo ( ) : void
Результат void

Reset() публичный Метод

Resets all internal variables, discarding edit tokens and so on, but does not logs off
public Reset ( ) : void
Результат void

Rollback() публичный Метод

public Rollback ( string title, string user ) : void
title string
user string
Результат void

Save() публичный Метод

public Save ( string pageText, string summary, bool minor, WatchOptions watch ) : SaveInfo
pageText string
summary string
minor bool
watch WatchOptions
Результат SaveInfo

SetBasicAuthHeader() защищенный Метод

Source: http://blog.kowalczyk.info/article/Forcing-basic-http-authentication-for-HttpWebReq.html
protected SetBasicAuthHeader ( WebRequest req, string userName, string userPassword ) : WebRequest
req WebRequest
userName string
userPassword string
Результат WebRequest

Titles() защищенный статический Метод

protected static Titles ( ) : string
Результат string

Unwatch() публичный Метод

public Unwatch ( string title ) : void
title string
Результат void

Watch() публичный Метод

public Watch ( string title ) : void
title string
Результат void

WatchAction() публичный Метод

public WatchAction ( string title, bool unwatch ) : void
title string
unwatch bool
Результат void

WatchOptionsToParam() защищенный статический Метод

protected static WatchOptionsToParam ( WatchOptions watch ) : string
watch WatchOptions
Результат string