php curl設(shè)置頭部信息的方法:首先把自定義http頭放入hearders array中;然后用“CURLOPT_HTTPHEADER”進(jìn)行設(shè)置即可。
推薦:《PHP視頻教程》
php curl設(shè)置自定義的HTTP頭
把自定義http頭放入hearders array, 然后用CURLOPT_HTTPHEADER設(shè)置。
$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);