واجهة برمجة التطبيقات:Validatepassword
هذه الصفحة جزء من توثيق واجهة برمجة تطبيقات ميدياويكي التي تحمل اسم Action. |
طلب POST الغرض منه التحقق من كلمة المرور مقارنة بسياسات كلمة المرور السارية على موقع الويكي.
إصدار ميدياويكي: | ≥ 1.29 |
توثيق واجهة برمجة التطبيقات
action=validatepassword(main | validatepassword)
Validate a password against the wiki's password policies. Validity is reported as Good if the password is acceptable, Change if the password may be used for login but must be changed, or Invalid if the password is not usable. Specific parameters: Other general parameters are available.
Examples:
|
مثال
طلب POST
التحقق من كلمة مرور مقارنة بسياسات كلمة المرور السارية على موقع الويكي.
النتيجة
{
"validatepassword": {
"validity": "Good"
}
}
عينة من الكود البرمجي
Python
#!/usr/bin/python3
"""
validatepassword.py
MediaWiki Action API Code Samples
Demo of `Validatepassword` module: Validate a password against the wiki's password policies.
MIT license
"""
import requests
URL = "https://en.wikipedia.org/w/api.php"
S = requests.Session()
PARAMS = {
"action": "validatepassword",
"format": "json",
"password": "",
}
R = S.post(URL, data=PARAMS)
DATA = R.json()
print(DATA)
PHP
<?php
/*
validatepassword.php
MediaWiki Action API Code Samples
Demo of `Validatepassword` module: Validate a password against the wiki's password policies.
MIT license
"""
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$validate_password = validatePassword();
function validatePassword() {
global $endPoint;
$params = [
"action" => "validatepassword",
"password" => "my_password",
"format" => "json"
];
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $endPoint );
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $params ) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
$output = curl_exec( $ch );
curl_close( $ch );
}
JavaScript
/*
validatepassword.js
MediaWiki Action API Code Samples
Demo of `Validatepassword` module: Validate a password against the wiki's password policies.
MIT license
*/
var request = require("request").defaults({jar: true}),
url = 'https://en.wikipedia.org/w/api.php';
function validatePassword() {
var params = {
action: "validatepassword",
password: "your_password",
format: "json"
};
request.post({ url: url, form: params }, function (error, res, body) {
if (error) {
return;
}
console.log(body);
});
}
MediaWiki JS
/*
validatepassword.js
MediaWiki Action API Code Samples
Demo of `Validatepassword` module: Validate a password against the wiki's password policies.
MIT license
*/
var params = {
action: "validatepassword",
password: "my_password",
format: "json"
},
api = new mw.Api();
api.postWithToken( 'csrf', params ).done( function ( data ) {
console.log( data );
} );
الأخطاء المحتملة
الكود | معلومات |
---|---|
userexists | اسم المستخدم الذي تم إدخاله مستعمل بالفعل.
الرجاء اختيار اسم مختلف. |
nopassword | يجب تعيين الوسيط password. |
baduser | قيمة غير صالحة "username" لوسيط المستخدم user. |
ملاحظات إضافية
- يشار إلى الصحة كما يلي:
Good
- لو كانت كلمة المرور مقبولةChange
- لو كان يجوز استخدام كلمة المرور لتسجيل الدخول إلا أنه يتعين تغييرهاInvalid
- لو كانت كلمة المرور لا يجوز استخدامها.