Packet-Fence/admin/elements/new_functions.php
2025-06-28 06:23:17 +05:30

27 lines
767 B
PHP

<?php
function make_get_request($url, $headers = []) {
$options = array(
'http' => array(
'header' => array_merge([
"accept: application/json"
], $headers),
'method' => 'GET',
'ignore_errors' => true
),
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
);
$context = stream_context_create($options);
$response = file_get_contents($url, false, $context);
// Get the response code
$http_code = isset($http_response_header) ? substr($http_response_header[0], 9, 3) : null;
// Return both the response and the HTTP status code
return ['response' => $response, 'http_code' => $http_code];
}
?>