Reputation: 317
I am familiar with displaying items from and XML feed using PHP, but an API I have just started working on requires me to include the HTTP Request header...
Feed-Auth => myPassword
How do I include a HTTP Request Header?
Upvotes: 1
Views: 185
Reputation: 12826
header("Feed-Auth:".$myPassword);
If you are hitting the API using something like curl
or soap
, they have their own mechanisms for setting headers.
Curl:
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Feed-Auth:'.$myPassword));
SOAP
$header = array('Feed-Auth'=>$myPassword);
$soapHeader = new SoapHeader('NAMESPACE','Header',$header,false);
$client->__setSoapHeaders($oapHeader);
Upvotes: 1
Reputation: 173522
You would have to load the document in another way and use simplexml_load_string()
:
$body = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'header' => 'Feed-Auth: myPassword',
),
)));
$doc = simplexml_load_string($body);
Upvotes: 0