API:Assert
| यह पृष्ठ मीडियाविकि क्रिया API प्रलेख का हिस्सा है। |
| मीडियाविकि संस्करण: | ≥ 1.23 |
क्रिया API का assert पैरामीटर अनुरोध के निष्पादित किए जाने से पहले विशिष्ट शर्तें सत्यापित करने के लिए किसी भी API अनुरोध पर सेट किया जा सकता है।
उपलब्ध विकल्प हैं:
assert=anon: जाँचें कि क्या आप IP सदस्य हैं। यह गलती से पंजीकृत खाते का उपयोग करने से रोकता है। MediaWiki 1.35 • change 572374 सेassert=user: जाँचें कि क्या आप पंजीकृत खाते (या तो "नामित" का अस्थायी) का उपयोग कर रहे हैं। यह गलती से IP सदस्य पर फ़ॉलबैक करने से रोकता है।assert=bot: जाँचें कि क्या आपने किसी ऐसे खाते से लॉग-इन किया हुआ है जिसमें "bot" सदस्य अधिकार है। यह आपके स्क्रिप्ट को ऐसे विकियों के साथ इंटरैक्ट करने से रोकता है जिन पर आपके बॉट के पास बॉट चिप्पी नहीं है।assertuser=...: जाँचें कि क्या आपने अपेक्षित सदस्यनाम से लॉग-इन किया हुआ है। MediaWiki 1.28 से
ध्यान रखें कि अस्थायी सदस्य assert=user को पूरा करते हैं मगर assert=anon को नहीं कर पाते हैं।
संभव त्रुटियाँ
अगर जाँच असफल रहती है तो निम्नलिखित में से कोई एक त्रुटि कोड लौटाया जाएगा:
assertanonfailedassertuserfailedassertbotfailedassertnameduserfailed
औचित्य और उपयोग के मामले
ये पैरामीटर्स कई तरह की समस्याओं से निपटने के लिए एक अतिरिक्त सुरक्षा उपाय हैं:
बॉट संचालक द्वारा त्रुटियाँ
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.
ऐसी गलतियों से बचने के लिए assert=bot और assertuser=... पैरामीटर्स उपलब्ध हैं।
लॉग-इन सत्र की समाप्ति
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).
इससे बचने के लिए assert=user पैरामीटर उपलब्ध है।
सदस्य खातों के बीच बदलना
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.
स्टैंडअलोन जाँच
अगर आप बिना कोई अन्य क्रिया किए यह जाँचना चाहते हैं कि क्या आपके HTTP क्लाइंट ने क्रिया API में लॉग-इन किया हुआ है, आप action=query&assert=user पैरामीटरों के साथ एक अनुरोध भेज सकते हैं।
अगर आपने लॉग-इन किया हुआ है तो यह एक खाली उत्तर लौटाएगा (JSON प्रारूप में {}), वरना assertuserfailed त्रुटि लौटाएगा।
साधारणतः आपको इस प्रकार का एक अलग अनुरोध करने की आवश्यकता नहीं होगी।
इसके बजाय अपने सभी अनुरोधों में assert=user पैरामीटर सेट कर लें।