参见英文答案 >
Making a HTTP GET request with HTTP-Basic authentication5个
我需要到达一个由.htaccess文件(Auth类型Basic,htpasswords等)保护的外部的.PHP页面.
我需要到达一个由.htaccess文件(Auth类型Basic,htpasswords等)保护的外部的.PHP页面.
我相信你可以用一个上下文去做:
$context = stream_context_create(array ( 'http' => array ( 'header' => 'Authorization: Basic ' . base64_encode("$username:$password") ) )); $data = file_get_contents($url,false,$context);