php curl的CURLOPT_HTTPHEADER可以自訂添加嗎?例如'Request-Id' => '1w11'

來源:互聯網
上載者:User

php curl的CURLOPT_HTTPHEADER可以自訂嗎?例如'Request-Id' => '1w11',我用$_SERVER沒接收到啊

回複內容:

php curl的CURLOPT_HTTPHEADER可以自訂嗎?例如'Request-Id' => '1w11',我用$_SERVER沒接收到啊

可以,手冊中格式,不建議這樣

CURLOPT_HTTPHEADER    設定 HTTP 頭欄位的數組。格式: array('Content-type: text/plain', 'Content-length: 100')---$head = array('Request-Id' => '1w11');curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 

建議直接放在data中

 '1w11');curl_setopt($ch, CURLOPT_URL, 'http://localhost/this.php');curl_setopt($ch, CURLOPT_POST, 1);curl_setopt($ch, CURLOPT_POSTFIELDS, $data);curl_exec($ch);?>

不可以 能說下你為什麼要這樣嗎

自己試試可以不不就行了,
應該可以的,google的api裡面都有,
如果還是不行,就自己去構建一個http協議格式,開TCP傳輸吧。

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.