API:अवरोध
Appearance
यह पृष्ठ मीडियाविकि प्रतिक्रिया API प्रलेख का हिस्सा है। |
Special:BlockList के प्रारूप में वर्तमान में अवरोधित सदस्यों की सूची पाने के लिए GET अनुरोध।
मीडियाविकि संस्करण: | ≥ 1.12 |
API प्रलेख
उदाहरण
तीन सबसे हाल के अवरोधों को सूचीबद्ध करता है
GET अनुरोध
api.php? action=query& list=blocks& bkprop=id|user|by|timestamp|expiry|reason|range|flags& bklimit=3& format=json [try in ApiSandbox]
जवाब
{
"batchcomplete": "",
"continue": {
"bkcontinue": "20190226192632|8865878",
"continue": "-||"
},
"query": {
"blocks": [
{
"id": 8865881,
"user": "168.11.166.47",
"by": "Gilliam",
"timestamp": "2019-02-26T19:28:56Z",
"expiry": "2020-02-26T19:28:56Z",
"reason": "{{school block}}",
"rangestart": "168.11.166.47",
"rangeend": "168.11.166.47",
"anononly": "",
"nocreate": "",
"allowusertalk": ""
},
{
"id": 8865880,
"user": "64.125.67.43",
"by": "Gilliam",
"timestamp": "2019-02-26T19:27:44Z",
"expiry": "2019-03-01T19:27:44Z",
"reason": "part of mass attack",
"rangestart": "64.125.67.43",
"rangeend": "64.125.67.43",
"anononly": "",
"nocreate": "",
"allowusertalk": ""
}
...
]
}
}
उदाहरण कोड
Python
#!/usr/bin/python3
"""
get_blocked_users.py
MediaWiki API Demos
Demo of `Blocks` module: GET request to list recent blocked users
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"bklimit": "3",
"list": "blocks",
"bkprop": "id|user|by|timestamp|expiry|reason|range|flags",
"format": "json"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
print(DATA['query']['blocks'])
PHP
<?php
/*
get_blocked_users.php
MediaWiki API Demos
Demo of `Blocks` module: GET request to list recent blocked users.
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "blocks",
"bklimit" => "3",
"bkprop" => "id|user|by|timestamp|expiry|reason|range|flags"
];
$url = $endPoint . "?" . http_build_query( $params );
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$output = curl_exec( $ch );
curl_close( $ch );
$result = json_decode( $output, true );
var_dump( $result["query"]["blocks"] );
JavaScript
/*
get_blocked_users.js
MediaWiki API Demos
Demo of `Blocks` module: GET request to list recent blocked users.
MIT License
*/
var url = "https://en.wikipedia.org/w/api.php";
var params = {
action: "query",
list: "blocks",
bklimit: "3",
bkprop: "id|user|by|timestamp|expiry|reason|range|flags",
format: "json"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
fetch(url)
.then(function(response){return response.json();})
.then(function(response) {console.log(response.query.blocks);})
.catch(function(error){console.log(error);});
MediaWiki JS
/*
get_blocked_users.js
MediaWiki API Demos
Demo of `Blocks` module: GET request to list recent blocked users.
MIT License
*/
var params = {
action: 'query',
list: 'blocks',
bklimit: '3',
bkprop: 'id|user|by|timestamp|expiry|reason|range|flags',
format: 'json'
},
api = new mw.Api();
api.get( params ).done( function ( data ) {
console.log( data.query.blocks );
} );
अतिरिक्त टिप्पणियाँ
- इस मोडल का इस्तेमाल सृष्टिकार के रूप में नहीं किया जा सकता।
पैरमीटरों का इतिहास
- v1.19:
bkshow
को जोड़ा गया - v1.18:
userid
को जोड़ा गया