YBthebest Posted November 22, 2010 Share Posted November 22, 2010 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! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 How about instead of posting a link that goes to a 301 error message, you tell us what is happening, versus what you expect to happen? Describe what you mean by "it doesn't seem to work". Quote Link to comment Share on other sites More sharing options...
YBthebest Posted November 22, 2010 Author Share Posted November 22, 2010 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... Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 22, 2010 Share Posted November 22, 2010 I'm by no means a curl expert either, but since you aren't setting a user agent string, I believe it's possible the server thinks a spambot or other "bad" user is attempting to log in, and tossing you aside. Quote Link to comment Share on other sites More sharing options...
rusking Posted November 22, 2010 Share Posted November 22, 2010 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? Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 22, 2010 Share Posted November 22, 2010 those are the names of the fields in the login form, or should be, for example: <input type='text' name='email-email' size='30'> <input type='password' name='password-password' size='30'> Quote Link to comment Share on other sites More sharing options...
rusking Posted November 22, 2010 Share Posted November 22, 2010 ooo ok to the source i go to find these fields Quote Link to comment Share on other sites More sharing options...
rusking Posted November 22, 2010 Share Posted November 22, 2010 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=" ? Quote Link to comment Share on other sites More sharing options...
rusking Posted November 22, 2010 Share Posted November 22, 2010 seems to work. Thank you Quote Link to comment Share on other sites More sharing options...
YBthebest Posted November 23, 2010 Author Share Posted November 23, 2010 Is it rworking for you? How? It still is not working for me...and no that website does not check on the useragent...arghh Still waiting for an answer! Thank you very much, I love you guys Quote Link to comment Share on other sites More sharing options...
rusking Posted November 23, 2010 Share Posted November 23, 2010 I works for me but i only used parts of it. Not the whole thing. I used my website and had it just loginto my forums. i can provide the code if you like but its only portions of the original Quote Link to comment Share on other sites More sharing options...
YBthebest Posted November 24, 2010 Author Share Posted November 24, 2010 Well if it can work for me...yes please ^^ I'm not sure at all, just need something :/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.