-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·40 lines (26 loc) · 1.13 KB
/
functions.php
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
35
36
37
38
39
40
<?php
// function get_wikipedia_main_picture_name($title) {
// var_dump($title);
// $title = str_replace(' ', '_', $title);
// var_dump($title);
// $page_url = 'http://fr.wikipedia.org/w/api.php?format=json&action=query&titles=' . $title . '&prop=pageimages&piprop=name&continue' ;
// var_dump($page_url);
// $raw_content = file_get_contents($page_url);
// $decoded_content = json_decode($raw_content);
// $content = $decoded_content->query->pages;
// $content = array_values((array)$content);
// if(!empty($content[0]->pageimage)) {
// $image_name = $content[0]->pageimage;
// return $image_name;
// }
// return FALSE;
// }
// function get_wikipedia_main_picture_file($image_name) {
// $image_url = 'http://fr.wikipedia.org/w/api.php?format=json&action=query&titles=File:' . $image_name . '&prop=imageinfo&iiprop=url&continue';
// $raw_content = file_get_contents($image_url);
// $decoded_content = json_decode($raw_content);
// $content = $decoded_content->query->pages;
// $content = array_values((array)$content);
// $distant_image = $content[0]->imageinfo[0]->url;
// return $distant_image;
// }