-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
37 lines (32 loc) · 1.03 KB
/
functions.php
File metadata and controls
37 lines (32 loc) · 1.03 KB
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
<?php
function loadConfig() {
$jsonPath = __DIR__ . '/config.json';
$jsonContent = file_get_contents($jsonPath);
if ($jsonContent !== false) {
$config = json_decode($jsonContent, true);
return $config;
}
}
function request($type, $url, $headerData = null) {
$options= array(
'http' => array(),
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
);
if ($headerData !== null)
$options['http'] = $headerData;
// Define the nature of the request GET, POST, etc.
$options['http']['method'] = $type;
// Make the request
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
if ($result === FALSE) {
return json_encode("{\"error\": \"Request error...\"}");
} else {
return json_decode($result, true);
}
return false;
}
?>