interpim Posted August 1, 2008 Share Posted August 1, 2008 So, I built a parser that will parse the HTML of a page, but the page I want to parse requires a username and a password to get to it. I have a username and password, but I cannot get my script to access the pages. I have tried cURL (maybe incorrectly) and it doesn't work... I have tried passing the variables to the page which it looks like the page requires me to do and it doesn't work I am trying to login to this page here http://realmwar.warhammeronline.com/realmwar/Index.war The parser just gets redirected back to this page when it cycles through the URL's I pass to it instead of the actual pages, indicating it isn't logging in. I am using WAMPP on the same machine that I have logged into the site with, but I still cannot get to it... can anyone offer any suggestions? Quote Link to comment Share on other sites More sharing options...
ShaunO Posted August 1, 2008 Share Posted August 1, 2008 You'll need to get all the form values that you need to send for curl You'll also need to setup a cookiejar to store the login cookie http://php.net/manual/en/function.curl-setopt.php Take a look at some of the options there and examples and you should get what you need. Quote Link to comment Share on other sites More sharing options...
interpim Posted August 1, 2008 Author Share Posted August 1, 2008 hmmm... can you explain the cookie jar? I have a cURL set up already for it. $URL="http://realmwar.warhammeronline.com/realmwar/Index.war"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"$URL"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "war_username=$user_name&war_password=$pword");curl_exec ($ch); curl_close ($ch); Quote Link to comment Share on other sites More sharing options...
ShaunO Posted August 1, 2008 Share Posted August 1, 2008 First off, you need to be posting to the actual login URL Which is this: http://realmwar.warhammeronline.com/realmwar/UserLoginAuthentication.war Then, you need to be passing the correct parameters, which is actually user and password like so: user=$user_name&password=$pword in the postfields option Then for the cookies and logging in, you need to add curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookiefilename"); curl_setopt($curl, CURLOPT_COOKIEJAR, "cookiefilename"); Then use curl_exec() and assign it to a variable so the output of the login page is stored like so $pageResults = curl_exec($ch); From there you can change the CURLOPT_URL to any page that requires you to be logged in and it should work. Quote Link to comment Share on other sites More sharing options...
interpim Posted August 2, 2008 Author Share Posted August 2, 2008 Thank you so much ShaunO It now works thanks to your help 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.