【发布时间】:2014-12-17 13:55:34
【问题描述】:
我想对另一台服务器进行 curl 调用以检索 pdf 文件 然后我想在我的 Drupal 网站上查看这个文件。 但是有一个问题:我们不能改变Drupal Module中的header!
$CurlConnect = curl_init();
$fields = array(
'param1' => $p1,
'param2' => $p2,
);
$fields_string = '';
foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');
curl_setopt($CurlConnect, CURLOPT_URL, 'http://test....');
curl_setopt($CurlConnect, CURLOPT_POST, 1);
curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($CurlConnect, CURLOPT_POSTFIELDS, $fields_string);
$Result = curl_exec($CurlConnect);
header('Cache-Control: public');
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="fichier.pdf"');
header('Content-Length: '.strlen($Result));
echo $Result;
【问题讨论】: