我尝试了一些不同的请求标题,从Firefox发送的标题开始。最小不工作:
[email protected]:~$ telnet www.caudalie.fr 80
Trying 178.16.174.50...
Connected to www.caudalie.com.
Escape character is '^]'.
GET/HTTP/1.1
Host: www.caudalie.fr
Connection: keep-alive
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 26 Apr 2013 07:23:36 GMT
Content-Type: text/html
Connection: keep-alive
Expires: Sat, 26 Jul 1997 05:00:00 GMT
Vary: Accept-Encoding
Content-Length: 0
我有一个重定向,如果我给语言:
[email protected]:~$ telnet www.caudalie.fr 80
Trying 178.16.174.50...
Connected to www.caudalie.com.
Escape character is '^]'.
GET/HTTP/1.1
Host: www.caudalie.fr
Accept-Language: nl,en;q=0.7,en-us;q=0.3
HTTP/1.1 302 Found
Server: nginx
Date: Fri, 26 Apr 2013 07:23:55 GMT
Content-Type: text/html
Connection: keep-alive
Expires: Sat, 26 Jul 1997 05:00:00 GMT
Location: http://fr.caudalie.com/
Vary: Accept-Encoding
Content-Length: 0
所以,加Accept-Language
头,你应该确定。在PHP中,这将是:
curl_setopt($http,CURLOPT_HTTPHEADER,array('Accept-Language: nl,en;q=0.7;en-us;q=0.3'));
也见这里:How to send a header using a HTTP request through a curl call?
我该地址获得了401。 – 2013-04-26 07:16:44
显示您的完整卷曲php代码 – shapeshifter 2013-04-26 07:18:23
也可能不是标题重定向? http://curl.haxx.se/docs/faq.html#Redirects_work_in_browser_but_no – shapeshifter 2013-04-26 07:20:21