【问题标题】:PHP - http_get not sending http_originPHP - http_get 不发送 http_origin
【发布时间】:2018-07-28 21:57:55
【问题描述】:

我正在做这样的 http_get 请求...

$response = http_get("http://www.example.com/test.php", array("timeout"=>1), $info);
print_r($info);

但是 test.php 有一个 $_SERVER['HTTP_ORIGIN'] 的请求,所以失败了。有没有办法告诉 http_get 请求发送这个值?

【问题讨论】:

    标签: php http-get


    【解决方案1】:

    您可以使用http_getoptions参数设置请求头

    $response = http_get( "http://www.example.com/test.php",
                          array(
                              "timeout"=>1,
                              "headers"=>array(
                                  "HTTP_ORIGIN" => "http://www.example2.com"
                              )
                          ), 
                          $info);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-11-27
      • 2017-05-05
      • 2011-03-05
      • 2022-06-15
      • 2011-10-15
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多