kish89 Posted September 11, 2008 Share Posted September 11, 2008 Hello, How can I automticly login to this site http://www.aukcije.hr/user_login.php I need to fetch some data from user area, but script first needs to login. Thanks. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted September 11, 2008 Share Posted September 11, 2008 Try cURL Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 11, 2008 Share Posted September 11, 2008 You would have to change the Content-Length for the length of your login info, but I think this would work. $fp = fsockopen("www.aukcije.hr", 80, $errno, $errstr, 30); if (!$fp) echo "$errstr ($errno)<br />\n"; else { $out = "POST /user_login.php HTTP/1.1\r\n"; $out .= "Host: www.aukcije.hr\r\n"; $out .= "Content-Type: application/x-www-form-urlencoded\r\n"; $out .= "Content-Length: 35\r\n"; $out .= "username=youruname\r\n"; $out .= "password=yourpass\r\n"; fwrite($fp, $out); $fbuff = ""; while (!feof($fp)) $fbuff .= fgets($fp, 128); fclose($fp); Quote Link to comment Share on other sites More sharing options...
kish89 Posted September 11, 2008 Author Share Posted September 11, 2008 Ive got this: Fatal error: Maximum execution time of 60 seconds exceeded in C:\xampp\htdocs\xampp\aukcije\login.php on line 18 Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 11, 2008 Share Posted September 11, 2008 That probably means that their server didn't recognize something in the packet. Make sure you are using the right Content-Length. Quote Link to comment Share on other sites More sharing options...
kish89 Posted September 12, 2008 Author Share Posted September 12, 2008 I've wrote good content lenght. I need only to count this, right? $out .= "Content-Length: 33 \r\n"; $out .= "username=xxxx89\r\n"; $out .= "password=xxxxxxxxx\r\n"; Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 12, 2008 Share Posted September 12, 2008 Woops, I guess you need to end the packet info part. Put another \r\n at the end of the Content-Length line: $out .= "Content-Length: 33 \r\n\r\n"; You will also want to echo out $fbuff to see what their server actually returns. Quote Link to comment Share on other sites More sharing options...
kish89 Posted October 23, 2008 Author Share Posted October 23, 2008 Now i dont have any errors. Only blank page. And it's not logged in.. 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.