Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit98910db

Browse files
zaycodesbrendajerop
authored andcommitted
Added Sample codes for API:Fileusage
1 parentcd67e79 commit98910db

File tree

9 files changed

+129
-2
lines changed

9 files changed

+129
-2
lines changed

‎javascript/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ Code snippets in Javascript demonstrating how to use various modules of the [Med
103103
*[revision_delete.js](revision_delete.js): Hide all information about a certain revision ID.
104104
*[API:Filearchive](https://www.mediawiki.org/wiki/API:Filearchive)
105105
*[file_archive.js](file_archive.js): Get a list of all deleted files.
106+
*[API:Fileusage](https://www.mediawiki.org/wiki/API:Fileusage)
107+
*[get_file_usage.js](get_file_usage.js): Get a list of pages using a given file.
106108

107109
###Search
108110
*[API:Search](https://www.mediawiki.org/wiki/API:Search)

‎javascript/get_file_usage.js‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//This file is autogenerated. See modules.json and autogenerator.py for details
2+
3+
/*
4+
get_file_usage.js
5+
6+
MediaWiki API Demos
7+
Demo of `Fileusage` module: Get a list of pages using a given file.
8+
9+
MIT License
10+
*/
11+
12+
varurl="https://en.wikipedia.org/w/api.php";
13+
14+
varparams={
15+
action:"query",
16+
titles:"File:Example.jpg",
17+
prop:"fileusage",
18+
format:"json"
19+
};
20+
21+
url=url+"?origin=*";
22+
Object.keys(params).forEach(function(key){url+="&"+key+"="+params[key];});
23+
24+
fetch(url)
25+
.then(function(response){returnresponse.json();})
26+
.then(function(response){console.log(response);})
27+
.catch(function(error){console.log(error);});

‎mediawikijs/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ These code snippets are usefull to create Userscripts and Gadgets.
167167
*[revision_delete.js](revision_delete.js): Hide all information about a certain revision ID.
168168
*[API:Filearchive](https://www.mediawiki.org/wiki/API:Filearchive)
169169
*[file_archive.js](file_archive.js): Get a list of all deleted files.
170+
*[API:Fileusage](https://www.mediawiki.org/wiki/API:Fileusage)
171+
*[get_file_usage.js](get_file_usage.js): Get a list of pages using a given file.
170172

171173
###Search
172174
*[API:Search](https://www.mediawiki.org/wiki/API:Search)

‎mediawikijs/get_file_usage.js‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// This file is autogenerated. See modules.json and autogenerator.py for details
2+
3+
/*
4+
get_file_usage.js
5+
6+
MediaWiki API Demos
7+
Demo of `Fileusage` module: Get a list of pages using a given file.
8+
9+
MIT License
10+
*/
11+
12+
varparams={
13+
action:'query',
14+
titles:'File:Example.jpg',
15+
prop:'fileusage',
16+
format:'json'
17+
},
18+
api=newmw.Api();
19+
20+
api.get(params).done(function(data){
21+
console.log(data);
22+
});

‎modules.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,13 +704,23 @@
704704
}
705705
},
706706
{
707+
<<<<<<< HEAD
707708
"filename":"file_archive",
708709
"docstring":"Demo of `Filearchive` module: Get a list of all deleted files.",
709710
"endpoint":"https://en.wikipedia.org/w/api.php",
710711
"params": {
711712
"action":"query",
712713
"list":"filearchive",
714+
=======
715+
"filename":"get_file_usage",
716+
"docstring":"Demo of `Fileusage` module: Get a list of pages using a given file.",
717+
"endpoint":"https://en.wikipedia.org/w/api.php",
718+
"params": {
719+
"action":"query",
720+
"titles":"File:Example.jpg",
721+
"prop":"fileusage",
722+
>>>>>>> Added Sample codes for API:Fileusage
713723
"format":"json"
714724
}
715725
}
716-
]
726+
]

‎php/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ Code snippets in PHP demonstrating how to use various modules of the [MediaWiki
171171
*[revision_delete.php](revision_delete.php): Hide all information about a certain revision ID.
172172
*[API:Filearchive](https://www.mediawiki.org/wiki/API:Filearchive)
173173
*[file_archive.php](file_archive.php): Get a list of all deleted files.
174+
*[API:Fileusage](https://www.mediawiki.org/wiki/API:Fileusage)
175+
*[get_file_usage.php](get_file_usage.php): Get a list of pages using a given file.
174176

175177
###Search
176178
*[API:Search](https://www.mediawiki.org/wiki/API:Search)

‎php/get_file_usage.php‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
//This file is autogenerated. See modules.json and autogenerator.py for details
4+
5+
/*
6+
get_file_usage.php
7+
8+
MediaWiki API Demos
9+
Demo of `Fileusage` module: Get a list of pages using a given file.
10+
11+
MIT License
12+
*/
13+
14+
$endPoint ="https://en.wikipedia.org/w/api.php";
15+
$params = [
16+
"action" =>"query",
17+
"titles" =>"File:Example.jpg",
18+
"prop" =>"fileusage",
19+
"format" =>"json"
20+
];
21+
22+
$url =$endPoint ."?" .http_build_query($params );
23+
24+
$ch =curl_init($url );
25+
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true );
26+
$output =curl_exec($ch );
27+
curl_close($ch );
28+
29+
$result =json_decode($output,true );
30+
var_dump($result );

‎python/README.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ Code snippets in Python demonstrating how to use various modules of the [MediaWi
177177
*[revision_delete.py](revision_delete.py): Hide all information about a certain revision ID.
178178
*[API:Filearchive](https://www.mediawiki.org/wiki/API:Filearchive)
179179
*[file_archive.py](file_archive.py): Get a list of all deleted files.
180-
180+
*[API:Fileusage](https://www.mediawiki.org/wiki/API:Fileusage)
181+
*[get_file_usage.py](get_file_usage.py): Get a list of pages using a given file.
182+
181183
###Search
182184
*[API:Search](https://www.mediawiki.org/wiki/API:Search)
183185
*[search.py](search.py): search for a title or a text

‎python/get_file_usage.py‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#This file is auto-generated. See modules.json and autogenerator.py for details
2+
3+
#!/usr/bin/python3
4+
5+
"""
6+
get_file_usage.py
7+
8+
MediaWiki API Demos
9+
Demo of `Fileusage` module: Get a list of pages using a given file.
10+
11+
MIT License
12+
"""
13+
14+
importrequests
15+
16+
S=requests.Session()
17+
18+
URL="https://en.wikipedia.org/w/api.php"
19+
20+
PARAMS= {
21+
"action":"query",
22+
"titles":"File:Example.jpg",
23+
"prop":"fileusage",
24+
"format":"json"
25+
}
26+
27+
R=S.get(url=URL,params=PARAMS)
28+
DATA=R.json()
29+
30+
print(DATA)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp