가능한 해결 방법은 HTTP 헤더를 사용하는 것입니다.
$urlToCall = '<get the link>';
$credentials = Crypt::createToken();
$reqHeaders = apache_request_headers();
// Configuring curl options extra:CURLOPT_HEADER => 1,
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Authorization: ' . $credentials)
);
$ch = curl_init($urlToCall);
curl_setopt_array($ch, $options);
$response = curl_exec($ch);
/*
//$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
//$header = substr($response, 0, $header_size);
//$body = substr($response, $header_size);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
list($headers, $content) = explode("\r\n\r\n", $response, 2);
foreach (explode("\r\n", $headers) as $hdr) {
header($hdr);
//echo $hdr . '<br>';
//print_r($hdr);
}
echo $content;
}
*/
if (curl_errno($ch)) {
print curl_error($ch);
} else {
header("Accept: " . $reqHeaders['Accept']);
$finfo = new finfo(FILEINFO_MIME);
header("Content-Type: " . $finfo->buffer($response));
print $response;
}
curl_close($ch);