【问题标题】:Drupal : curl call + view file pdfDrupal:curl 调用 + 查看文件 pdf
【发布时间】: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;

【问题讨论】:

    标签: php drupal-7


    【解决方案1】:

    不确定它是否会起作用,但希望它有所帮助

    可能从挂钩菜单项中调用函数

    你可以使用drupal_http_request代替usgin curl(这个函数不使用curl)

    在返回 pdf 之前,将标题更改为 drupal_add_http_header

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多