首页 新闻 搜索 专区 学院

PHP cURL 获取不到正确的cookie

0
悬赏园豆:50 [待解决问题]
    <?php
        $login_url="http://233.233.233.235:81/tmweb/login.aspx"; //假地址 
        $cookie_file=dirname(__FILE__)."/tmp.cookie";
        $verify_code_url="http://233.233.233.235:81/tmweb/VerifyCode.aspx?";
        $contents_url="http://233.233.233.235:81/tmweb/ischool.aspx";
        
        $Index_id=isset($_POST['Index_id']) ? $_POST['Index_id'] : "";
        $Index_pass=isset($_POST['Index_pass']) ? $_POST['Index_pass'] : "";
        $Index_rob=isset($_POST['Index_rob']) ? $_POST['Index_rob'] : "";
        $Index_valid=isset($_POST['Index_valid']) ? $_POST['Index_valid'] : "";
        if($Index_id=="" || $Index_pass=="" || $Index_rob=="" || $Index_valid=="")
        {
            echo "取cookie...";
            $curl=curl_init();
            $timeout=5;
            curl_setopt($curl,CURLOPT_URL,$login_url);
            curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
            curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout);
            curl_setopt($curl,CURLOPT_COOKIEJAR,$cookie_file);
            $contents=curl_exec($curl);
            curl_close($curl);
            
            echo "取验证码...";
            $curl=curl_init();
            curl_setopt($curl,CURLOPT_URL,$verify_code_url);
            curl_setopt($curl,CURLOPT_COOKIEFILE,$cookie_file);
            curl_setopt($curl,CURLOPT_HEADER,0);
            curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
            $img=curl_exec($curl);
            curl_close($curl);
            
            $fp=fopen("verifyCode.jpg","w");
            fwrite($fp,$img);
            fclose($fp);
            echo "验证码得到完成...";
        }
        else
        {
            $post = array(
            'cobRole' => $Index_rob,
            'User_ID' => $Index_id,
            'User_Pass' => $Index_pass,
            'txtVolidate' => $Index_valid,
            '__LASTFOCUS' => '',
            '__EVENTTARGET' => '',
            '__EVENTARGUMENT' => '',
            '__VIEWSTATE' => '/wEPDwUINzk1NDY2NzEPZBYCAgMPZBYSAgMPDxYCHgRUZXh0BRcyMDE4LjMuM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Y29iUm9sZSREREQFB2dyaWROZXcqRtKKDp9c9mj1g0v8M2VCC3QUMEnHPs96cef5XvCfsA==',
            '__EVENTVALIDATION' => '/wEWCALFzrzIAQLLrZqPCAKqydOsDAKjp/vdAQLzpqn0DwLs9tTtBQKM54rGBgLXk6LaBgYPk5VBTPwsl/++JKvx7WwT5xXKrhHotmJxDyaaDk6a',
            'cobRole_VI' => 'bdfeb86e-3c29-4696-a19d-6c428850cea3',
            'cobRole_DDDWS' => '0:0:-1:0:0:0:0:0:',
            'cobRole_DDD_LDeletedItems' => '',
            'cobRole_DDD_LInsertedItems' => '',
            'cobRole_DDD_LCustomCallback' => '',
            'cobRole$DDD$L' => 'bdfeb86e-3c29-4696-a19d-6c428850cea3',
            'cobRole$DDD$L$CVS' => '',
            'cobRole$CVS' => '',
            'Button1' => '',
            'gridNew$DXSelInput' => '',
            'gridNew$CallbackState' => '/wEWBB4ERGF0YQWgA0FBQUFBQUVBQUFBQUFBQUFBUUFBQUFBREFBQUFDRk5VVG1WM2MwbEVDRk5VVG1WM2MwbEVDd0FBQlVselRtVjNCVWx6VG1WM0NnQUFET21BbXVlZnBlUy9vZWFCcnd6cGdKcm5uNlhrdjZIbWdhOEhBQUFMQUFBQUNVNWxkM05VYVhSc1pRdE9aWGR6UTI5dWRHVnVkQWxKYzNOMVpVUmhkR1VKU1hOemRXVkVaWEIwQ0ZCWFZYTmxja2xFQmxKbGJXRnlhdzFKYzBSbFptRjFiSFJFYVhOd0NVNWxkM05UWTI5d1pRaE9aWGR6UzJsdVpBZFNaV0ZrVG5WdENrMXZaR2xtZVVSaGRHVUhBQWNBQndBSEFBYi8vd3NDaXg0UTFkanNxRUc2SXVKRURrNkF2Z29DQVFjQ1RlaXZ0K1drcCtXdXR1Uzl2K2l2dCtXa3ArV3V0dVM5ditlVXFFbEZNVER2dkl4SlJURXg3N3lNTXpZdzVvQ2w2WUNmNXFpaDVieVA1cldQNktlSTVabW9LREV4SURNd0lESXdNVGNwHgVTdGF0ZQVEQndFSEFBSUJCd0FIQUFjQUJ3QUNBQWIvL3drQ0NGTlVUbVYzYzBsRUNRSUFBZ0FEQndRQ0FBY0FBZ0VIQUFJQkJ3QT0=',
            '_submit' => '登录'
            );
            
            $curl=curl_init();
            curl_setopt($curl, CURLOPT_URL, $login_url);
            curl_setopt($curl, CURLOPT_HEADER, false);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($post));
            curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);
            $result=curl_exec($curl);
            curl_close($curl);
            //print_r($result);
        }
    ?>

获取cookie之后 带着cookie进行post登陆的时候会提示验证码错误 我猜测应该是cookie的问题

打开cookie文件之后确实有猫腻

现在的问题是 获取到的cookie似乎不正确 他是这样的

如果一行的最前面是'#'的话 这一行应该是被注释的 请问这是什么问题?辛苦了

PHP
EasyWorld的主页 EasyWorld | 初学一级 | 园豆:152
提问于:2018-03-04 03:10
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册