我用 Fiddler 抓取了以下 Post 请求,我只屏蔽了 URL,因为我不想做广告
POST http://xyz.com/dialogs/track HTTP/1.1
Host: www.xyz.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/10.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: de
Accept-Encoding: gzip, deflate
DNT: 1
Content-Type: application/json; charset=utf-8
X-CSRFToken: uuihXszJrkrXwnCkLKKDNQ8BrPRDqXvU
X-Requested-With: XMLHttpRequest
Referer: http://www.xyz.com/referer/
Content-Length: 2
Cookie: csrftoken=uuihXszJrkrXwnCkLKKDNQ8BrPRDqXvU
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
{}
我需要一个教程(链接很有用)来用 Curl “伪造”这个请求,我在 Google 上找到了一些东西,但没有任何工作,我收到错误。
-编辑-
$headers = array(
'POST http://www.example.com/dialogs/track HTTP/1.1',
'Host: www.example.com',
'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/10.0',
'Accept: application/json, text/javascript, */*; q=0.01',
'Accept-Language: de',
'Accept-Encoding: gzip, deflate',
'DNT: 1',
'Content-Type: application/json; charset=utf-8',
'X-CSRFToken: uuihXszJrkrXwnCkLKKDNQ8BrPRDqXvU',
'X-Requested-With: XMLHttpRequest',
'Referer: http://www.example.com',
'Content-Length: 2',
'Cookie: __cfduid=d0db16cb5c4c58db770a1374f09a61d7d1375100590810; csrftoken=uuihXszJrkrXwnCkLKKDNQ8BrPRDqXvU; __utma=1.2111538523.1375265099.1375427020.1375431064.5; __utmz=1.1375348556.2.2.utmcsr=example.de|utmccn=(referral)|utmcmd=referral|utmcct=/game/index.php; __gads=ID=88f0a0a8b0698e1e:T=1375265099:S=ALNI_MYX8OxkwPxXQd7VY4qDImLK7fq_yQ; __utmb=1.4.9.1375431089319; __utmc=1',
'Connection: keep-alive',
'Pragma: no-cache',
'Cache-Control: no-cache',
'',
'{}'
);
//set POST variables
$url = 'http://www.example.com/dialogs/track';
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
//execute post
$result = curl_exec($ch);
//close connection
if (curl_error($ch)) {
print "Error: " . curl_error($ch);
}
else
{
var_dump($data);
curl_close($ch);
}
错误信息
错误:接收失败:对等方重置连接
-编辑2-
我玩了一点,现在连接正常,但似乎 CSRF 令牌未正确提交,我收到一个错误!
禁止 (403)
CSRF 验证失败。请求中止。
他们是一个解决方案吗?