I need to reach a foreign .php page protected by a regular .htaccess file (Auth type Basic, htpasswords etc...).
I'd like to send the user and password needed through the request. Is it possible? I would like to avoid cURL
and all pecl_http
dependent functions if possible...
Off-hand, I believe you can use a context to do that:
$context = stream_context_create(array (
'http' => array (
'header' => 'Authorization: Basic ' . base64_encode("$username:$password")
)
));
$data = file_get_contents($url, false, $context);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With