curl login without post statement

Discussion in 'PHP' started by ntesla123, Apr 6, 2011.

  1. #1
    I'm trying to use curl to log into a site like this one.

    http://www.celebritymoviearchive.com/members/

    When I try to use live httpheaders to find out which variables are being posted, I cant find any. There isn't any post function. How do I log into a site like this?

    The site uses a get statement with
    Authorization: Basic bmxwdGVjaDFAaG90bWFpbC5jb206eGVobW51NGU=

    This is the data that's sent:


    GET /members/ HTTP/1.1

    Host: www.celebritymoviearchive.com

    User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.04 (lucid) Firefox/3.6.16

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    Accept-Language: en-us,en;q=0.5

    Accept-Encoding: gzip,deflate

    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

    Keep-Alive: 115

    Connection: keep-alive

    Authorization: Basic bmxwdGVjaDFAaG90bWFpbC5jb206eGVobW51NGU=



    HTTP/1.1 200 OK

    Date: Wed, 06 Apr 2011 22:07:35 GMT

    Server: Apache/2.2

    X-Powered-By: PHP/5.3.6

    Content-Encoding: gzip

    Vary: Accept-Encoding

    Content-Length: 2608

    Keep-Alive: timeout=15, max=100

    Connection: Keep-Alive

    Content-Type: text/html
     
    ntesla123, Apr 6, 2011 IP
  2. Jan Novak

    Jan Novak Peon

    Messages:
    121
    Likes Received:
    5
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Hi
    Try this - found at http://php.bigresource.com/Track/php-p8WkKqkq/:

    
    $url = "http://www.domain.com";
    $postFields = "Param1=Val1&Param2=Val2";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "username:password");
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
    $xmlResponse = curl_exec($ch);
    
    Code (markup):
     
    Jan Novak, Apr 7, 2011 IP