显示另一个启用身份验证的页面内容


Display of another authentication enabled page content?

如何显示已启用身份验证的其他页面的内容?

警告:file_get_contents(http://abc/report.cmd?report=123):无法打开流:HTTP请求失败!HTTP/1.1第13行上//html/tracker/index2.php中要求的401授权

    $file_path = 'http://abc/report.cmd?report=123';
    $content=file_get_contents($file_path);
    echo $content;

使用curl库验证

<?php
// create a new cURL resource
$curl = curl_init();
// set URL and other appropriate options
curl_setopt($curl, CURLOPT_URL, "http://www.example.com/");
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC ) ; 
curl_setopt($curl, CURLOPT_USERPWD, "username:password"); 
// grab URL and pass it to the browser
curl_exec($curl);
// close cURL resource, and free up system resources
curl_close($curl);
?>

首先进行身份验证。。,然后请求请求内容。

下面是一个针对HTTPBasic身份验证w/PHP:进行身份验证的示例

http://php.net/manual/en/features.http-auth.php