Home > Article > Backend Development > How to set header information in php curl
php curl method to set header information: first put the custom http header into the hearders array; then use "CURLOPT_HTTPHEADER" to set it.
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!