ページの保護レベルを変更するために、protectトークンが必要です。このトークンはeditトークンと等しくすべてのページに対して同じですが、ログインするごとに変わります。protectトークンは次のように取得できます:
| 結果 |
| The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?>
<api>
<query>
<pages>
<page
pageid="1"
counter="20"
length="470"
protecttoken="58b54e0bab4a1d3fd3f7653af38e75cb+\"
/>
</pages>
</query>
</api>
|
| The above content has been placed in a collapsed box for improved usability. |
ページの保護 [edit]
ページの保護はaction=protextでできます。
title: 保護したいページ。
token: 以前のリクエストで取得されたトークン。'+'を'%2B'にurlencodeすることに注意して下さい。
protections: action=group、例えばedit=autoconfirmed|move=sysopなどとしてフォーマットされた保護のパイプで区切られた一覧表
- 保護を取り除きたい場合は、グループとしてallを使います。例えばedit=all|move=sysopです。
- アクションを除外する場合、関連した値は変わりません。すなわちedit=sysopはmove protectionをそのままにします。
expiry: GNUタイムスタンプ形式の期限のタイムスタンプ。The first timestamp applies to the first protection in protections, the second to the second, etc. 'infinite'、'indefinite、'never'、もしくはまったく設定されない場合、保護は期限切れにならなくなります。'next Monday 16:04:57'もしくは'9:28 PM tomorrow'のようなタイムスタンプも許可されます。
- The number of expiry timestamps must equal the number of protections, or you'll get an error message
- An exception to this rule is made for backwards compatibility: if you specify exactly one expiry timestamp, it'll apply to all protections
- Not setting this parameter is equivalent to setting it to
infinite
reason: 保護(保護解除)の理由(オプション)。
cascade: 設定されると、保護されたページにトランスクルードされるページも保護されます。編集するために必要なユーザレベルは保護するために必要なユーザレベルよりも低く(例えばedit=autoconfirmed)、cascadingは有効にできず、このパラメータは暗黙のうちに無視されます。
- 後者はページを保護することができない人々がcascading保護を持つページでそれらをトランスクルードすることでそれらを保護することをできないようにするということです。
Note: In this example, all parameters are passed in a GET request just for the sake of simplicity. However, action=protect requires POST requests; GET requests will cause an error.
| 結果 |
| The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?>
<api>
<protect title="Main Page" reason="" cascade="">
<protections>
<protection edit="autoconfirmed" expiry="24-10-2007T16:07:54Z" />
<protection move="sysop" expiry="infinite" />
</protections>
</protect>
</api>
|
| The above content has been placed in a collapsed box for improved usability. |
| 結果 |
| The following content has been placed in a collapsed box for improved usability. |
<?xml version="1.0" encoding="utf-8"?>
<api>
<protect title="Deletion log" reason="Don't create this for now">
<protections>
<protection create="sysop" expiry="2008-03-08T16:34:30Z" />
</protections>
</protect>
</api>
|
| The above content has been placed in a collapsed box for improved usability. |
起こり得るエラー [edit]
通常のものに加えて、次のものがあります:
- code: notitle
- info: titleパラメータを設定しなけれればなりません
- code: notoken
- info: tokenパラメータを設定しなければなりません
- code: noprotections
- info: protectionsパラメータを設定しなければなりません
- code: invalidexpiry
- info: 無効な有効時間
- 有効なタイムスタンプが無効な形でフォーマットされたもしくは存在しないことを意味します(例えばNovember 31もしくは24:05)。
- code: pastexpiry
- code: toofewexpiries
- info: number expiry timestamps were provided where number were needed
- Note that this error is misnamed: it's also thrown when you specify too many expiry times
- code: cantedit
- info: このページを編集できないので保護できません
- code: create-titleexists
- info: 既存のタイトルは'create'で保護できません
- code: missingtitle-createonly
- info: 見つからないタイトルは'create'でのみ保護できます
- code: protect-invalidaction
- info: Invalid protection type ``type''
- code: protect-invalidlevel
- info: Invalid protection level ``level''