-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
45 lines (29 loc) · 968 Bytes
/
Copy pathfunctions.php
File metadata and controls
45 lines (29 loc) · 968 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
35
36
37
38
39
40
41
42
43
44
45
<?php
/* DOCS: https://www.freetogame.com/api-doc */
function err($s) {
echo "<pre>";
print_r($s);
echo "</pre>";
}
define('GAMES_PATH', "https://www.freetogame.com/api/games");
define('GAME_PATH', "https://www.freetogame.com/api/game");
function getAPI($url, $taxonomy = "", $value = "") {
if( !empty($taxonomy) ) :
$url .= "?" . $taxonomy . "=" . $value;
else :
$url;
endif;
if( !empty( $taxonomy ) && empty( $value ) ) :
echo "ERROR: Value is empty!";
endif;
$json = file_get_contents($url);
$json_decode = json_decode( $json );
return $json_decode;
}
function getMultiAPI($url, $platform, $category, $sort_by) {
$url .= "?platform={$platform}&category={$category}&sort-by={$sort_by}";
$json = file_get_contents($url);
$json_decode = json_decode( $json );
return $json_decode;
}
//err(getAPI("https://www.freetogame.com/api/games", "category", "shooter"));