php curl post请求中携带header参数

curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); 

或者

  $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; 
  $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; 
  $header[] = "Cache-Control: max-age=0"; 
  $header[] = "Connection: keep-alive"; 
  $header[] = "Keep-Alive: 300"; 
  $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; 
  $header[] = "Accept-Language: en-us,en;q=0.5"; 
  $header[] = "Pragma: "; // browsers keep this blank. 
  curl_setopt($curl, CURLOPT_HTTPHEADER, $header); 
转载自:https://www.cnblogs.com/devcjq/articles/6080391.html

参考:

https://www.php.net/manual/zh/function.curl-setopt.php

里面的 CURLOPT_HTTPHEADER 属性。

php curl post请求中携带header参数

注意 CURLOPT_HTTPHEADER 的格式:使用示例

//设置
 $headers = [
            'Content-Type:application/plan',
            'pf:'.$pf
        ];

// 使用
curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);

 

上一篇:菜鸟电子面单 类 php


下一篇:PHP中使用CURL实现GET和POST请求数据