Jump to content

[cURL]Login to a website and get the content of a page


YBthebest
 Share

Recommended Posts

Hello!

 

I would like to use cURL to login to the website: lockerz.com

 

I have some code, but it doesn't seem to work:

<?php
// INIT CURL
$ch = curl_init();

// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login');

// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD');

// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);

// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction');

// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);

// CLOSE CURL
curl_close ($ch); 
echo $content;
?>

 

Thank you very much if you can help!

Link to comment
Share on other sites

Sorry for that!

 

Well the problem it, it should show me the page with the auctions (prizes) but it shows me the 301 ( it's on Lockerz.com's server, you can see that at the bottom of the page ). Maybe the login is not OK? I don't really know cURL very well.

 

Thank you so much...

Link to comment
Share on other sites

is this section editable to user and pass? Becuase i tried user and made it for my forums with no luck

// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD');

 

I guess im asking....why does it say email-email? are these fields to declare it then what the login refers it as? if so in which order?

Link to comment
Share on other sites

I found this

<label>Username *<br />
        <input type="text" name="log" id="user_login" class="input" value="" size="20" tabindex="10" /></label>
    </p>

    <p>
       <label>Password<br />
        <input type="password" name="pwd" id="user_pass" class="input" value="" size="20" tabindex="20" /></label>
    </p>

 

So does that mean for "e-mail-email=" i use "log=" on user

and "password=password=" i use "pwd=" ?

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.