Curl Login

Discussion in 'PHP' started by Silver89, Mar 12, 2008.

  1. #1
    Hi,

    I'm trying to login to hi5.com with Curl, im using the following but getting no luck at all :confused:, am i on the right track?

    <?
    	$ch = curl_init(); 
    	
    	curl_setopt($ch, CURLOPT_URL, "http://hi5.com/");
    	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);	
    	curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
        curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    
    	curl_setopt ($ch, CURLOPT_HEADER, 1);
    
    	$html = curl_exec($ch); 
    	echo $html;
    	curl_close ($ch);
    	
    ?>
    PHP:
     
    Silver89, Mar 12, 2008 IP
  2. Taikumi

    Taikumi Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try using getcwd() for the cookie paths.

     
    Taikumi, Mar 12, 2008 IP
  3. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #3
    Still no luck sadly
     
    Silver89, Mar 12, 2008 IP
  4. J.T.D.

    J.T.D. Peon

    Messages:
    86
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You want to login, right? If so use this:

    <?php
        $post_stuff = 'email=test@example.com&password=PASSWORDOOOOO';
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, 'http://hi5.com/friend/login.do');
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);   
        curl_setopt($ch, CURLOPT_HEADER, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $post_stuff);
    
        $html = curl_exec($ch);
        echo $html;
        curl_close ($ch);
    ?>
    PHP:
    Edit the line, $post_stuff to change to the login email/password. That should login for you ;).

    - JTD
     
    J.T.D., Mar 12, 2008 IP
  5. Silver89

    Silver89 Notable Member

    Messages:
    2,243
    Likes Received:
    72
    Best Answers:
    0
    Trophy Points:
    205
    #5
    Yes, but how can i save those cookies it gives me and just have the cookies log me in
     
    Silver89, Mar 12, 2008 IP
  6. Gani

    Gani Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi Grunt, your code to login in hi5 using cURL is 'Nice',
    How can i update my profile using cURL, any idea ? if so please provide me the specific code
     
    Gani, May 2, 2008 IP