次の PHP コードを使用して、特定のヘッダーと Cookie を含む GET 要求を送信しています。
$getheader = array(
"Accept: text/html, application/xhtml+xml, */*",
"Accept-Language: en-US",
"User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
"Accept-Encoding: gzip, deflate",
"Host: mysite.com",
"Connection: Keep-Alive"
);
curl_setopt($ch, CURLOPT_URL, 'http://mysite.com');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $getheader);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt'); //read from the cookie
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_exec($ch);
正常に動作していますが、次のようにヘッダーが間違った順序で送信されます。
GET http://mysite.com/ HTTP/1.1
Cookie: remember_me=1; id=9089018083 <------ this line should be at the end
Accept: text/html, application/xhtml+xml, */*
Accept-Language: en-US
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept-Encoding: gzip, deflate
Host: mysite.com
Connection: Keep-Alive
Cookie はヘッダーの後に送信する必要があります (Web ブラウザーが行うように) が、私の場合は何が問題なのかわかりません。助けていただけますか?
ありがとう