Home  >  Article  >  Backend Development  >  How to set header information in php curl

How to set header information in php curl

藏色散人
藏色散人Original
2020-08-21 09:00:292419browse

php curl method to set header information: first put the custom http header into the hearders array; then use "CURLOPT_HTTPHEADER" to set it.

How to set header information in php curl

Recommended: "PHP Video Tutorial"

php curl sets custom HTTP header

Put the custom http header into the hearders array, and then set it with CURLOPT_HTTPHEADER.

$headers = array();
$headers[] = 'X-Apple-Tz: 0';
$headers[] = 'X-Apple-Store-Front: 143444,12';
$headers[] = 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
$headers[] = 'Accept-Encoding: gzip, deflate';
$headers[] = 'Accept-Language: en-US,en;q=0.5';
$headers[] = 'Cache-Control: no-cache';
$headers[] = 'Content-Type: application/x-www-form-urlencoded; charset=utf-8';
$headers[] = 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:28.0) Gecko/20100101 Firefox/28.0';
$headers[] = 'X-MicrosoftAjax: Delta=true';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

The above is the detailed content of How to set header information in php curl. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn