我正在尝试使用cURL和PHP将特定的HTTP标头发送到网站。
当我单击此站点的链接时,使用FireBug分析网络时,我会看到调用此链接的所有POST和GET方法。这里有标题。
回应标题:
Connection Keep-Alive
Content-Encoding gzip
Content-Length 20
Content-Type text/html; charset=utf-8
Date Mon, 31 Dec 2012 12:55:57 GMT
Keep-Alive timeout=5, max=100
Location http://www.example.com/a/b/11111
Server Apache/2.2.22
Vary Accept-Encoding
X-Powered-By PHP/5.3.10-1ubuntu3.4
请求标题:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3
Connection keep-alive
Cookie referee_id=number;authautologin=number;session=number;uber_video=number
DNT 1
Host www.example.com
Referer http://www.referersite.com
User-Agent Mozilla/5.0 (Windows NT 6.1;WOW64;rv:17.0) Gecko/17.0 Firefox/17.0
发送数据回复标题
Content-Length 6
Content-Type application/x-www-form-urlencoded
然后,在FireBug中,可以选择在新选项卡中再次发送所需的方法。它发送它,它似乎我点击了链接,但我真的没有点击,我使用HTTP标头。我希望它能做到这一点,但使用cURL。 在这里你可以选择我说:http://img5.imageshack.us/img5/3841/sinttulodho.png(Abrir ennuevabraaña=在新标签中打开)
所以这是我的尝试:
<?
$url = 'http://www.example.com/a/b/1?c=1';
function disguise_curl($url) {
$curl = curl_init();
$header[] = "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
$header[] = "Cache-Control: max-age=0";
$header[] = "Connection: keep-alive";
$header[] = "Keep-Alive:timeout=5, max=100";
$header[] = "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3";
$header[] = "Accept-Language:es-ES,es;q=0.8";
$header[] = "Pragma: ";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11');
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
curl_setopt($curl, CURLOPT_REFERER, 'http://www.referersite.com');
curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate,sdch');
curl_setopt($curl, CURLOPT_AUTOREFERER, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 10);
$html = curl_exec($curl);
curl_close($curl);
}
echo disguise_curl($url);
?>
我没有让它发挥作用。在代码中使用HTTP标头或其他错误的任何其他方法吗?