I am trying to retrieve some data from an API that requires authentication via HTTPS. I have the correct authentication, however when using 'file_get_contents' to get the data I am getting the error:
failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request
$api_url = 'https://api...';
$client_id = 'user';
$client_secret = 'pass';
$context = stream_context_create(array(
'http' => array(
'header' => "Authorization: Basic " . base64_encode("$client_id:$client_secret"),
),
));
$result = file_get_contents($api_url, false, $context);
Would there be any particular reason why I am unable to get the data from the authenticated server?