API:Data formats/zh

输入
API是通过询问字符串以提供该参数，或者是来自application/x-www-form-urlencoded或multipart/form-data的POST实体为获取所输入的数据格式. 每个模块（以及每个的子模块）都会有自己一组的参数，它们都列于文档中以及action=help的模块内. 它们也可以通过为重新检索.

编码
所有输入在UTF-8，以及NFC的表格里应当是有效的. MediaWiki将会尝试转换为其他的格式，这或许会导致程序上的错误.

多值参数
一些参数可采用多个值的设置，通过管道字符中的以分隔出来. For example, to submit the three values,  , and   for the parameter  , you would put   in the query. Whether a parameter accepts multiple values is listed explicitly in  and. The documentation does not distinguish multivalue parameters explicitly, but the descriptions for these parameters are usually along the lines of "A list of ..." or "A pipe-separated list of ...".

If you need to submit a list of values where some of the values contain a pipe character (which should be rare - most multivalue parameters are lists of page titles or usernames, neither of which can contain pipes), you can use the unit separator character instead:  (where  stands for U+001F) will submit the three values ,   and. (Note that there is an extra  at the beginning. This is mandatory to avoid ambiguity around submitting a single value containing a pipe.)

布尔值
Boolean parameters work like HTML checkboxes: if the parameter is specified in the HTTP request, regardless of value, it is considered true. For a false value, omit the parameter entirely. The best way to specify a true parameter in an HTTP request is to use ; the trailing   ensures the browser or HTTP library does not discard the "empty" someParam.

时间戳
Parameters that take timestamp values accept multiple timestamp formats:


 * ISO 8601格式:
 * MySQL的内部时间戳格式:
 * UNIX时间戳格式  (自1970年1月1日以来的秒数)
 * UNIX时间戳格式  (自1970年1月1日以来的秒数)

输出时，时间戳总是ISO 8601格式.

输出
MediaWiki API has historically supported a number of different formats, but this has significantly complicated further development. We would like to standardize on just one JSON format. For now, MediaWiki discourages, but still supports two additional generic output formats (XML and PHP). You should always specify the format with the input (request) parameter  and a lowercase value. Feed modules like Feed Recent Changes override the standard output format, instead using RSS or Atom, as specified by their  parameter. In those cases, the format specified in the  parameter is only used if there's an error. 除了JSON以外的其他格式都已经过期. XML和PHP仍然还支持，但是其他所有格式已经在 MediaWiki 1.26 或 1.27 中删除，详见下表. 所有新的API用户应当使用JSON. Clients written in PHP should avoid using the PHP format because it is fundamentally insecure. It is maintained for now only due to its popularity.

Unless specified, all modules allow data output in all generic formats. To simplify debugging, all generic formats have "pretty-print in HTML" alternatives with an  suffix.

The default format changed in MediaWiki 1.25 to ; it was   in earlier MediaWiki releases.

Note that while the pretty-print formats are all indented and separate syntactic elements with newlines, the non-pretty formats don't do this.

There are many conversion libraries and online converters to convert JSON responses to other formats—for example, JSON-CSV converts to Comma-Separated Values

JSON参数
and  accept the following additional parameters:


 * Specify  for to get json (and php) format responses in a cleaner format. This also encodes most non-ASCII characters as UTF-8.
 * Specify  for to get json (and php) format responses in a cleaner format. This also encodes most non-ASCII characters as UTF-8.
 * Specify  for to get json (and php) format responses in a cleaner format. This also encodes most non-ASCII characters as UTF-8.

回调函数限制
When using JSON in callback mode, a number of things are disabled for security:


 * Tokens cannot be obtained (so state-changing actions aren't possible)
 * The client is treated as an anonymous user (i.e. not logged in) for all purposes, even after logging in through
 * This means that things that require additional rights, such as, won't work unless anonymous users are allowed to use them

例子
it may be useful to add the '&indexpageids' parameter, to parse the json if the pageid ("736") is not known before the result.