I'm working with an api that returns a number of useful variables within the header response, for example with...
Pragma → no-cache
Server → Apache
X-Pages → 1424
... I'd like to use the X-Pages variable to form some further logic. How do I retrieve this variable and use it within my php script?
My api currently call looks like this:
$username = "XXXXXXXX";
$password = "XXXXXXXX";
$remote_url = 'XXXXXXXX';
$headers = array();
$headers[] = "Authorization: Basic " . base64_encode("$username:$password");
$opts = array(
'http'=>array(
'method'=>"GET",
'header' => $headers
)
);
$context = stream_context_create($opts);
$file1 = file_get_contents($remote_url, false, $context);
Thanks,
Matt