API:Account creation/zh

创建一个账户
此流程有3個步驟：


 * 1) 从获取字段，从获取令牌.
 * 2) 使用获取的令牌、用户信息等字段发送POST请求，并将URL返回给API.
 * 3) 处理返回结果，这可能涉及进一步的POST请求以提供更多信息.

示例1：没有特殊身份验证扩展的wiki的过程
在没有特殊身份验证扩展的wiki上处理是相当简单的. 如果你的代码知道哪些字段是必填的，它可以跳过对的调用并假设需要哪些字段（即用户名，密码和重复输入的密码，邮箱，可能还有真名）.

Example 2: Process on a wiki with a CAPTCHA extension
Note the first step below could, if you'd rather, be done as two steps: one to fetch the fields available from and another to fetch the token from.

示例代码
Note this code sample separates the and  requests, and generally assumes there will be a CAPTCHA and no other complications.

First step: Fetch fields available from and token from
The fetching of and  is largely the same as in the previous example, and so is not repeated here. The list of requests returned by will include definitions for both the CAPTCHA extension and the OpenID extension.

Second step: Answer the CAPTCHA and select OpenID authentication.
The client would be expected to redirect the user's browser to the provided redirecttarget.

The OpenID provider would authenticate, and redirect to Special:OpenIDConnectReturn on the wiki, which would validate the OpenID response and then redirect to the createreturnurl provided in the first POST to the API with the code and state parameters added.

The client gets control of the process back at this point and makes its next API request.

Third step: Back from OpenID.
The client posts the code and state back to the API. The API's response has the two-factor authentication extension prompting the user to set up their second factor.

Now the client would prompt the user to set up a new account in their two-factor authentication app and enter the current code, or allow the user to skip 2FA setup. 我们假设用户确实设置了2FA（双因素验证）.

第四步：设置双因素身份验证.
帐户创建终于成功了.

If at any point account creation fails, a response with status FAIL will be returned, along with a message to display to the user.

附加提醒

 * 帐户创建记录在Special:log/newusers.

如果您已登录，则在创建帐户时您的用户名也会被记录.


 * 在执行此页面上提供的代码段时，请记住：
 * 一旦创建维基上的帐户，将无法删除该帐户.
 * Always use as the endpoint, so that you don't accidentally create accounts on production wikis.
 * MediaWiki site administrators and extension developers can disable this API feature by inserting the following line in the configuration file: