dopii22884 2019-01-28 17:42
浏览 116

POST后的CURL(PHP)和重定向

I use CURL and PHP to mirror remote web site and it's works fine, but when I try to make POST request with parameters, after CURL received reply from remote server with new "Location:" header, it's not send to user browser (I only see it in curl headers).

I need to redirect user to new location after POST query to remote site. This location received by header reply of remote server, but this not provided to end user browser.

Please help me to find solution. I checked a lot of search engine results with no luck. I only find some advices for command-line curl, but not for PHP.

Thank you!

curl_setopt_array($curl,$x=array(
    //CURLOPT_HEADER=>1,
    CURLINFO_HEADER_OUT=>1,
    CURLOPT_RETURNTRANSFER=>1,
    CURLOPT_FOLLOWLOCATION=>true,
    CURLOPT_MAXREDIRS=>7,
    CURLOPT_AUTOREFERER=>true,
    CURLOPT_PROXY=>$proxy,
    CURLOPT_PROXYTYPE=>7,
    //CURLOPT_COOKIESESSION=>false,
    CURLOPT_COOKIEFILE=>$_SESSION['cookie_4'],
    CURLOPT_COOKIEJAR=>$_SESSION['cookie_4'],
    CURLOPT_REFERER=>$referer,
    CURLOPT_ENCODING=>"gzip",
    CURLOPT_HTTPHEADER=>array(
        "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
        "Accept-Language: en-US,en;q=0.5",
        "Accept-Encoding: gzip, deflate",
        "Cache-Control: no-cache",
        "Connection: keep-alive",
        "Pragma: no-cache",
        "Upgrade-Insecure-Requests: 1",

    ),
    CURLOPT_USERAGENT=>/*isset($_SERVER['HTTP_USER_AGENT']) ? (string)$_SERVER['HTTP_USER_AGENT'] : */'Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0',
));
  • 写回答

1条回答 默认 最新

  • drvonr6573 2019-01-28 17:58
    关注

    just pass through the headers received by curl to the browser?

    curl_setopt($curl,CURLOPT_HEADERFUNCTION,function($ch,$header){
        header($header);
        return strlen($header);
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建