API:令牌(操作)
Jump to navigation
Jump to search
![]() | 本页是MediaWiki Action API文档的一部分。 |
tokens | ||
---|---|---|
Gets tokens for data-modifying actions. 此模块不能用作generator。 |
||
前缀 | ||
需要的权限 | 无 | |
仅限Post? | 否 | |
产生帮助 | 当前 | |
添加的版本 |
|
For the current method of obtaining tokens via a meta module, see: API:Tokens.
Since MW 1.24, the action=tokens is deprecated and includes a warning "Please use action=query&meta=tokens instead".
Tokens can be obtained using action=tokens. These tokens can then be used in other API requests.
参数
type
: the type of token requested.block
delete
edit
email
import
move
options
patrol
protect
rollback
unblock
watch
The Central Auth extension on MediaWiki servers adds the following tokens:deleteglobalaccount
setglobalaccountstatus
示例
Getting an edit token (default behavior)
结果 |
---|
<?xml version="1.0"?>
<api>
<tokens edittoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" />
</api>
|
Getting several tokens at once
结果 |
---|
<?xml version="1.0"?>
<api>
<tokens edittoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" emailtoken="6c82e3a4f17f52ff1e2e4a16b64fed10+\" patroltoken="0eaa2666f8c6c0779c43acbdf9703c4a+\" watchtoken="22dff2c0b0c1bef9ad34673b81b91f22+\" />
</api>
|
可能的错误
In addition to the usual errors, other errors may be returned in the following format:
<?xml version="1.0"?>
<api>
<warnings>
<tokens>无法识别的参数<var>type</var>的值:test。</tokens>
</warnings>
<tokens/>
</api>
可能的错误包括:
- 无法识别的参数type的值:value。
- 操作“xxx”不允许当前用户使用。
Failing to urlencode the token can result in an invalid token error.
重要提醒
You need to send the cookie obtained in the login phase when you call the api with the "tokens" action; otherwise you get the cryptic "readapidenied" error.
API documentation
action=tokens(main | tokens)
Get tokens for data-modifying actions. This module is deprecated in favor of action=query&meta=tokens. Parameter:
Examples:
|