Trying to connect to ASPX site using CURL?

后端 未结 3 1990
醉话见心
醉话见心 2021-02-03 12:08

I am trying to log into this url:

http://www.kalahari.com/marketplace/default.aspx

The two fields that are being submitted are labelled:

<
3条回答
  •  抹茶落季
    2021-02-03 12:33

    I wanted to give it a try and got your code working, see below. I have some var_dump and comments in the code as to what I am doing.

     rawurlencode($viewstate),
        "__EVENTVALIDATION" => rawurlencode($validation),
        "ctl00%24ctl00%24ucMarketPlaceSupportNavigation%24txtMPTopSignInEmail" => rawurlencode($username),
        "ctl00%24ctl00%24ucMarketPlaceSupportNavigation%24txtMPTopSignInPasswordTextNormal" => "Password",
        "ctl00%24ctl00%24ucMarketPlaceSupportNavigation%24txtMPTopSignInPassword" => rawurlencode($password),
        "ctl00%24ctl00%24ucMarketPlaceSupportNavigation%24btnSigninTop" => "Sign+in",
    );
    var_dump($postfields);
    
        //I created the string myself for the post, else I got an error because we already encoded the variable names.
    $p = "";
    foreach($postfields as $k=>$v) {
        $p .= $k.'='.$v.'&';
    }
    
    
    //do the new post
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $p);
    $ret = curl_exec($ch);//Get result after login page.
    
        //this contains 'You have entered an invalid password' so it works as expected.
    var_dump($ret);
    
    ?>
    

提交回复
热议问题