CURL and login

Discussion in 'PHP' started by iAreCow, Jan 18, 2010.

  1. #1
    Good day,

    I need to make CURL get a hash code from a page, and then
    use it to perform a POST action, while both of them being
    in one session (seperate sessions will not work because of the
    hash mismatch).

    In the following code, CURL pushes the page into $res variable,
    then the explosion part follows and the final hash code is stored in $hash2,
    now I need to perform a POST action using $hash2 within the very same
    CURL session.

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://www.annaabi.com/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $res = curl_exec($ch);
    curl_exec($ch);
    
    $hash1 = explode('<input type="hidden" value="',$res);
    $hash2 = substr($hash1[1],0,32);
    echo $hash2;
    PHP:
     
    Last edited: Jan 18, 2010
    iAreCow, Jan 18, 2010 IP
  2. iAreCow

    iAreCow Peon

    Messages:
    85
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    iAreCow, Jan 18, 2010 IP