- http認証が有効になっている別のサーバーからのURLがあります。
- この特定のURLは、ファイルにファイルのダウンロードを強制します。
ここでヘッダーを取得してヘッダーを元に戻そうとしているので、curlでhttp authが実行された後、phpファイルから強制的にダウンロードできますが、成功しません。カールはエラーを出しませんでした。$bodyには何も返されません。
$url=$_GET["url"];//another web server url which forcing file download save as $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_USERPWD, "username:password");//http auth done here curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, null); curl_setopt($ch, CURLOPT_URL, $url); $response = curl_exec($ch); list ($headerString, $body) = explode("\r\n\r\n", $response, 2); $headers = explode("\r\n", $headerString); foreach ($headers as $header) { header($header); } echo $body; exit;