I am trying to authenticate with this site https://vatstats.net/api/v1/flights/ via headers with file_get_contents
with this code:
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Content-Type: application/json en
" .
"Authorization: Token 7f0c76c1930e9519e3408bebfaef79524db6185b
"
)
);
$response = file_get_contents("https://vatstats.net/api/v1/flights/?format=json", false, stream_context_create($opts));
echo $response;
But for some reason it fails. The API instructions are these:
All requests to the API must be sent with the API token provided above. Without the token only demo information will be shown which is five records per url. This token must be in the Authorization header.
The key should be prefixed by the string literal "Token", with whitespace separating the two strings.
As an example: Authorization: Token fd705d56d3a02d46a23d9dc356334f923ff54aa6