PHP Curl表单发布返回服务器404错误

时间:2017-02-19 22:13:54

标签: php curl post

我想发布3个步骤表格。在步骤1中成功获取csrf令牌并发布和服务器返回步骤2,其中再次获取csrf令牌并获取输入并发送到服务器但服务器返回404错误和一些时间503错误。在浏览器整个过程中工作正常。我也用标题饼干检查,但没有运气。

当我提交帖子时,服务器将我带到404错误的错误页面

我的第2步代码是。请帮助我,我做错了什么

$url2 = $myurl;
$cookie= "cookie.txt";

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url2);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_fields));

//curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
              'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:51.0) Gecko/20100101 Firefox/51.0',
                                            'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
                                            'Accept-Language: en-US,en;q=0.5',
                                            //'Accept-Encoding: gzip, deflate, br',
                                            'Connection: keep-alive',
                                            'Upgrade-Insecure-Requests: 1',
                                            'Content-Type: application/x-www-form-urlencoded',
                                            'Content-Length: '.strlen(http_build_query($post_fields)).''
                                            ));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPGET, true);

$html = curl_exec($ch);

print($html);

这里是curl info,

[content_type] => text/html; charset=utf-8
    [http_code] => 200
    [header_size] => 840
    [request_size] => 1781
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 1
    [total_time] => 1.342852
    [namelookup_time] => 4.7E-5
    [connect_time] => 4.7E-5
    [pretransfer_time] => 0.000139
    [size_upload] => 0
    [size_download] => 19782
    [speed_download] => 14731
    [speed_upload] => 0
    [download_content_length] => 19782
    [upload_content_length] => -1
    [starttransfer_time] => 0.409502
    [redirect_time] => 0.899697
    [redirect_url] => 
    [request_header] => GET /Error/NotFound/ HTTP/1.1

Cookie: ASP.NET_SessionId=sgtn2gjp3vnwlzbc1o2rynzj; DMVCT=!BUmY9FBUSeg9vX773mngcy6iownJceIg25o7msKCbRyyVGsdwBy8m4hIW/0LMfGBVtSj8+BtUJt5SsY=; __RequestVerificationToken_Lw__=9dQ9gm4pcFwkc/QnNu60FNwimLtF6QdGsQUKC+jH08DUVjy6q+LOu3ivRcWXGyIFdp9tmiEf0VBkEmLQsdCb6DWvbqz3I+ifny5z/5V4PgVb1g2bJAjaaIVHCGmFCqQ4t0jTPXcTRwuOoFHx6mV/+hexuqlMgf9jbxAz67AylzU=; akavpau_wr=1487539428~id=f84c8dd5fd74c88b432ad0ea211e66df
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:51.0) Gecko/20100101 Firefox/51.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 473

0 个答案:

没有答案