Skip to content

Commit 0f6ebd5

Browse files
Jayprakash-SEsrish
authored andcommitted
Added get_blocked_users module
1 parent 2bfd1fb commit 0f6ebd5

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

javascript/get_blocked_users.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//This file is autogenerated. See modules.json and autogenerator.py for details
2+
3+
/*
4+
get_blocked_users.js
5+
6+
MediaWiki API Demos
7+
Demo of `Blocks` module: GET request to list recent blocked users.
8+
9+
MIT License
10+
*/
11+
12+
var url = "https://en.wikipedia.org/w/api.php";
13+
14+
var params = {
15+
action: "query",
16+
list: "blocks",
17+
bklimit: "3",
18+
bkprop: "id|user|by|timestamp|expiry|reason|range|flags",
19+
format: "json"
20+
};
21+
22+
url = url + "?origin=*";
23+
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
24+
25+
fetch(url)
26+
.then(function(response){return response.json();})
27+
.then(function(response) {console.log(response.query.blocks);})
28+
.catch(function(error){console.log(error);});

mediawikijs/get_blocked_users.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This file is autogenerated. See modules.json and autogenerator.py for details
2+
3+
/*
4+
get_blocked_users.js
5+
6+
MediaWiki API Demos
7+
Demo of `Blocks` module: GET request to list recent blocked users.
8+
9+
MIT License
10+
*/
11+
12+
var params = {
13+
action: 'query',
14+
list: 'blocks',
15+
bklimit: '3',
16+
bkprop: 'id|user|by|timestamp|expiry|reason|range|flags',
17+
format: 'json'
18+
},
19+
api = new mw.Api();
20+
21+
api.get( params ).done( function ( data ) {
22+
console.log( data.query.blocks );
23+
} );

modules.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,5 +525,17 @@
525525
"atnamespace": "0",
526526
"atlimit": "3"
527527
}
528+
},
529+
{
530+
"filename": "get_blocked_users",
531+
"docstring": "Demo of `Blocks` module: GET request to list recent blocked users.",
532+
"endpoint": "https://en.wikipedia.org/w/api.php",
533+
"params": {
534+
"action": "query",
535+
"list": "blocks",
536+
"bklimit": "3",
537+
"bkprop": "id|user|by|timestamp|expiry|reason|range|flags",
538+
"format": "json"
539+
}
528540
}
529541
]

php/get_blocked_users.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
//This file is autogenerated. See modules.json and autogenerator.py for details
4+
5+
/*
6+
get_blocked_users.php
7+
8+
MediaWiki API Demos
9+
Demo of `Blocks` module: GET request to list recent blocked users.
10+
11+
MIT License
12+
*/
13+
14+
$endPoint = "https://en.wikipedia.org/w/api.php";
15+
$params = [
16+
"action" => "query",
17+
"format" => "json",
18+
"list" => "blocks",
19+
"bklimit" => "3",
20+
"bkprop" => "id|user|by|timestamp|expiry|reason|range|flags"
21+
];
22+
23+
$url = $endPoint . "?" . http_build_query( $params );
24+
25+
$ch = curl_init( $url );
26+
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
27+
$output = curl_exec( $ch );
28+
curl_close( $ch );
29+
30+
$result = json_decode( $output, true );
31+
var_dump( $result["query"]["blocks"] );

0 commit comments

Comments
 (0)