forked from wikimedia/mediawiki-api-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget_imageusage.php
More file actions
34 lines (25 loc) · 765 Bytes
/
get_imageusage.php
File metadata and controls
34 lines (25 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
//This file is autogenerated. See modules.json and autogenerator.py for details
/*
get_imageusage.php
MediaWiki API Demos
Demo of `Imageusage` module: List the first 3 pages that use a given image title
MIT License
*/
$endPoint = "https://en.wikipedia.org/w/api.php";
$params = [
"action" => "query",
"format" => "json",
"list" => "imageusage",
"iutitle" => "File:Wiki_logo_Nupedia.jpg",
"iulimit" => "3"
];
$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 );
foreach( $result["query"]["imageusage"] as $k => $v ) {
echo( $v["title"] . "\n" );
}