API:Import/zh

POST请求以另一个维基（跨维基）或xml文件导入页面.

示例
导入页面是一个多步骤的过程：  使用中描述的方法之一登录.  获取. 所有页面的巡查令牌是相同的，但是每次登录时巡查令牌会改变.

 发送带有CSRF令牌的POST请求以导入页面.  

下面的示例代码详细介绍了第3步.

示例代码
For simplicity, the following code is reading the XML from a textarea and makes use of MediaWiki's JavaScript includes.

这只是一个最小的实现. 不要忘记错误处理. 如果您将导出的文件用作上传，并希望使其在不能充分支持Blob和FormData的旧浏览器中工作，那么只需构建一个HTML表单即可. The form's target could be an iframe so you can read the response from it without exposing the blank API result page to your users.

使用httpclient的Ruby源代码示例（假设登录cookies已经在@headers中）.

可能的错误
除了：

参数历史

 * v1.29: 启用
 * v1.20: 启用

附加提醒

 * 该模块不可用作.
 * rights are required in order to upload an xml file, while  rights are required for interwiki imports.
 * If you get a  error, it is because you sent it url-encoded but claimed it would be multipart/form-data. MediaWiki is looking for a boundary in the header but cannot find it.
 * Parameters marked with  are only used when importing an uploaded XML file. Similarly, parameters marked with   are only used when importing from another wiki (transwiki).
 * The possible values for the  parameter differ per wiki, see . If the list of possible values for this parameter is empty, interwiki imports are disabled.

参见

 * Special:Export - Export the text and editing history of a particular page or set of pages wrapped in some XML.
 * 通过API.
 * - 上传一个文件.