API:जाँच

This page is a translated version of the page API:Assert and the translation is 3% complete.
Outdated translations are marked like this.
मीडियाविकि संस्करण:
1.23

The assert parameter of the Action API can be set on any API request to verify certain conditions before the requested action is executed.

The available options are:

  • assert=anon: Check that you are acting as an IP user . This prevents accidental use of a registered account. MediaWiki 1.35change 572374 से
  • assert=user: Check that you are using a registered account (either "named" or temporary). This prevents accidental fallback to an IP user.
  • assert=bot: जाँचता ह कि आपके खाते पर "बॉट" सदस्य अधिकार है कि नहीं This prevents your script from interacting with wikis where your bot does not have the bot flag.
  • assertuser=...: Check that you are logged-in with the expected user name. MediaWiki 1.28 से

Note that temporary users satisfy assert=user, and fail assert=anon.

अगर जाँच असफ़ल रहती है, त्रुटि कोड $1 या $2 दिखाए जाएँगे।

  • assertanonfailed
  • assertuserfailed
  • assertbotfailed
  • assertnameduserfailed

Rationale and use cases

These parameters are intended as a second line of defense against several kinds of problems:

Bot operator errors

It's easy for a simple operator error to cause a lot of bad edits, such as the bot running on the wrong wiki or under the wrong username, especially if you're running more than one bot task. The assert=bot and assertuser=... parameters are intended to help prevent those mistakes.

Login session expiration

After logging in, the cookies you receive are only valid for 30 days by default, after which time your bot will become logged out, and may continue working with its actions being attributed to the IP address or a temporary username (if logged-out users are allowed to perform them).

The assert=user parameter is intended to prevent this.

Switching user accounts

Interactive tools (in the browser) using the API to edit often want to make sure the user understands how their work will be attributed.

When the user logs in or out in another browser tab (or their login session expires), this won't be immediately reflected in the tool's interface, but the new login session will be used for saving actions. The assertuser=... and assert=anon parameters are intended to allow detecting this scenario and displaying an appropriate message before continuing.


जाँचना कि आपने लॉग-इन किया है कि नहीं

अगर आप बस यह जाँचना चाहते हैं कि आपने प्रतिक्रिया API पर लॉग-इन किया है कि नहीं, आप पैरामीटर action=query&assert=user के साथ एक अनुरोध जारी कर सकते हैं। अगर आपने लॉग-इन किया हुआ है तो यह एक साधारण खाली जवाब लौटाएगा (JSON प्रारूप में {}), वरना assertuserfailed लौटाएगा।

साधारणतः आपको यह करने की ज़रूरत नहीं होगी। इसके बजाय उन सभी अनुरोधों पर assert=user पैरामीटर जोड़ दें जो लॉग-इन किए हुए सदस्य द्वारा किए जाने चाहिए।