[英]how to set headers for curl in php when using xampp
$headerSet=array(
'GET'.$url,
'Host: verify-email.org',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:28.0) Gecko/20100101 Firefox/28.0',
'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language: en-gb,en;q=0.5',
'Accept-Encoding: gzip, deflate',
'Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Proxy-Connection: Close',
'Cookie: __utma=67582614.1178183750.1396541997.1396541997.1396550804.2; __utmz=67582614.1396541997.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); __atuvc=3%7C14; b38b8c1b3d6a4a2d4cc2696153b7cd63=lv63r03hdfq0p66ohv13brhlq5; __utmb=67582614.2.10.1396550804; __utmc=67582614',
'Cache-Control: max-age=0',
'Connection: keep-alive',
'DNT: 1'
);
$ch = curl_init(); // Initialising cURL
$data = curl_exec($ch); // Executing the cURL request and assigning the returned data to the $data variable
curl_close($ch); // Closing cURL
return $data; // Returning the data from the function
現在添加此代碼后,我嘗試運行程序,但仍未設置標頭。 我也已經簽入了httpsfox。 主機是localhost,但是我希望主機設置為verify-email.org
從標題數組中刪除'GET'.$url,
。 並將網址放在curl_init
$ch = curl_init($url); // <- url is placed here, and it will be GET by default
而且我沒有看到您使用curl設置$headerSet
。 像這樣做:
curl_setopt($ch, CURLOPT_HTTPHEADER, $headerSet);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.