Fetches all HTTP request headers from the current request with
apache_request_headers();
look at php.net apache-request-headers
if apache_request_headers() is not available, loop trough the superglobal $_SERVER
and get info you need, the request headers starting with HTTP_
, like
$headers = array();
foreach ($_SERVER as $key => $value) {
if (preg_match('/^HTTP_.+/', $key)) {
// sanitize keys removing HTTP_
$headers[str_replace('HTTP_','',$key)] = $value;
}
}
to use
echo $headers['API-Key'];