curl.net https页面登录问题500内部服务器错误


curl .net https page login problem 500 Internal Server Error

当我尝试使用curl登录页面时,我会收到500内部服务器错误。页面位于https上。

这里是登录功能:

 function login ($login, $pass) {
    $loginURL = "https://bitomat.pl/Account/LogOn";
    $loginPage = $this->curl->getPage($loginURL);
    $numStart = strpos(htmlentities($loginPage['content']), "type="hidden" value="");
    $numEnd = strpos(htmlentities($loginPage['content']), "<fieldset>");
    $verNum = substr(htmlentities($loginPage['content']), $numStart+36, 64);
    echo $numStart." - ".$numEnd." - ".$verNum."<br>";
    $page = $this->curl->post($loginURL, "__RequestVerificationToken=".urlencode($verNum)."&UserName=$login&Password=".urlencode($pass)."&RememberMe=false");
    echo nl2br(htmlentities($page['content']));
}

作为回应,我得到:

   HTTP/1.1 500 Internal Server Error
   Cache-Control: private
   Content-Type: text/html; charset=utf-8
   Server: Microsoft-IIS/7.0
   X-AspNetMvc-Version: 2.0
   X-AspNet-Version: 4.0.30319
   X-Powered-By: ASP.NET
   Date: Sat, 25 Jun 2011 16:32:18 GMT
   Content-Length: 3974

CUrl post功能:

function post($url, $params) {
    $rnd = rand(0, 10000000000);
    $options = array(
        CURLOPT_COOKIESESSION => true,
        CURLOPT_COOKIEFILE => "cookie/cookieBitomat",// . $rnd,
        CURLOPT_COOKIEJAR => "cookie/cookieBitomat",// . $rnd,
        CURLOPT_RETURNTRANSFER => true, // return web page
        CURLOPT_HEADER => true, // don't return headers
        CURLOPT_FOLLOWLOCATION => true, // follow redirects
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $params,
        CURLOPT_USERAGENT => "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1", // who am i
        CURLOPT_AUTOREFERER => true, // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 60, // timeout on connect
        CURLOPT_TIMEOUT => 60, // timeout on response
        CURLOPT_MAXREDIRS => 20, // stop after 10 redirects
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_VERBOSE => TRUE,
        CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded",
            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
            "Host: bitomat.pl",
            "Accept-Language: pl,en-us;q=0.7,en;q=0.3",
            "Accept-Encoding: gzip, deflate",
            "Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.7",
            "Keep-Alive: 115",
            "Connection: keep-alive",
            "Referer: https://bitomat.pl/Account/LogOn"
            )
    );

    $ch = curl_init($url);
    curl_setopt_array($ch, $options);
    $content = curl_exec($ch);
    $err = curl_errno($ch);
    $errmsg = curl_error($ch);
    $header = curl_getinfo($ch);
    curl_close($ch);
    $header['errno'] = $err;
    $header['errmsg'] = $errmsg;
    $header['content'] = $content;
    return $header;
}

在这种情况下,通常会得到500,因为您的HTTP请求与浏览器在这种情况中所做的请求有些不同,并且服务器端脚本对此进行了假设。

确保你检查了一个"实时"请求,并尽可能地模仿它。