-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagent-data-loader.php
More file actions
34 lines (34 loc) · 1018 Bytes
/
agent-data-loader.php
File metadata and controls
34 lines (34 loc) · 1018 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
$url = filter_input(INPUT_GET, 'url', FILTER_SANITIZE_SPECIAL_CHARS);
$api_url = $url;
// Initializing curl
$ch = curl_init( $api_url );
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array(
'Accept: application/xml',
'Content-type: text/plain'
)
);
// Setting curl options
curl_setopt_array( $ch, $options );
// Getting results
$result = curl_exec($ch); // Getting JSON result string
$curl_errno = curl_errno($ch); // store here to use later if needed
$curl_error = curl_error($ch);
$curl_http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
//echo json_encode(curl_getinfo($ch));
// close cURL resource, and free up system resources
curl_close($ch);
if ($curl_errno) {
echo json_encode(array('curl_error' => $curl_error));
} else if ($curl_http_code == "403") {
echo json_encode(array(
'status' => 403,
'message' => 'Forbidden Access',
'responseText' => $result
));
} else {
echo $result;
}