使用curl-PHP登录

使用curl-PHP登录,php,ssl,curl,Php,Ssl,Curl,我想写一个脚本,在PHP中使用curl登录。我写了这段代码,当我尝试使用这段脚本时,始终显示消息:“用户名或密码不正确”,但如果我给出相同的用户名和密码,我将登录 我不知道这个系统还需要什么,我的代码现在看起来像: $curl=curl_init("http://plemiona.pl/page/auth"); curl_setopt($curl,CURLOPT_HEADER,1); curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla

我想写一个脚本,在PHP中使用curl登录。我写了这段代码,当我尝试使用这段脚本时,始终显示消息:“用户名或密码不正确”,但如果我给出相同的用户名和密码,我将登录

我不知道这个系统还需要什么,我的代码现在看起来像:

    $curl=curl_init("http://plemiona.pl/page/auth");
    curl_setopt($curl,CURLOPT_HEADER,1);
    curl_setopt($curl,CURLOPT_USERAGENT,"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0");
    curl_setopt($curl,CURLOPT_REFERER,"http://plemiona.pl/");
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);

    curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);   
    curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE);

    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,  0);

    curl_setopt($curl, CURLOPT_COOKIEFILE, "D:\cookies.txt");
    curl_setopt($curl, CURLOPT_COOKIEJAR, "D:\cookies.txt");
    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($curl, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded",
                                                "X-Requested-With: XMLHttpRequest",
                                                "POST /page/auth HTTP/1.1", 
                                                "Host: www.plemiona.pl",
                                                "Accept: */*",
                                                "Accept-Language: pl,en-US;q=0.7,en;q=0.3",
                                                "Content-Length: 48"));

curl_setopt($curl, CURLOPT_POST, true);
$postVars = array('username' => 'username', 
                      'password' => 'pass', 
                      'remember' => '0',);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postVars);        
    $dw=curl_exec($curl);
    echo $dw;
当我尝试手动登录时,firefox http头将显示:

发送带有卷曲的帖子后,我的文件包含cookies:
.plemiona.pl真/假1520687485 cid 705415657

所以没什么:(

可能我必须使用正确的SSL证书才能使用:curl\u setopt($curl,CURLOPT\u SSL\u VERIFYPEER,TRUE)?
或者我应该搜索什么来修复它?

查看请求标题,可能您在post字段中遗漏了一些内容。不可能。没有其他字段:(您是否尝试删除CURLOPT_COOKIEFILE?是的,没有更改:(我不知道应该在哪里搜索问题:(