hey.
i have a php script which processes special http post requests. all these post requests have an additional key-value pair in their header wherein the key is called 'Authorization'.
so i have a php script which is getting these types of post requests and i know how to get the body data of the post request using $_POST['key'].
but i want to also get the value of the header key, 'Authorization'. i am unsure how to get the value of this header. can I use $_SERVER['Authorization']?
thanks in advance.
getting the headers from a HTTP POST request
Moderator: General Moderators
Re: getting the headers from a HTTP POST request
Take a look at this.
Re: getting the headers from a HTTP POST request
Try this, you might find it useful:
Code: Select all
foreach($_POST as $key=>$value)
{
$$key = $value;
echo $$key.": ".$value."<br />";
}
Re: getting the headers from a HTTP POST request
If PHP is installed as apache module: apache_request_headers();
I think PHP also populates custom headers in $_SERVER with X_ prefix, but I'm not sure what are the conditions to do this anyway, so I'm never relying on this.
I think PHP also populates custom headers in $_SERVER with X_ prefix, but I'm not sure what are the conditions to do this anyway, so I'm never relying on this.