Welcome to WebmasterWorld Guest from 54.162.240.235

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Trying to automate login

automate login

     
1:58 pm on Nov 10, 2009 (gmt 0)

5+ Year Member



Hi, I'm trying to write a simple PHP app to automate my login to thepiratebay.org, however when I send the correct login details, nothing is returned only an HTTP OK response without a login cookie. When I send the wrong details I get a web page saying the login details are incorrect. Any ideas? Here's my code:


<?PHP

$user="";
$pass="";

$postData="username=" . $user . "&password=" . $pass . "&act=login&submit=Login";

// login to google account

$ch = curl_init();

curl_setopt($ch, CURLOPT_COOKIEJAR, "/cookie_pb.txt");
curl_setopt($ch, CURLOPT_URL,"http://thepiratebay.org/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

ob_start(); // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output

curl_close ($ch);
unset($ch);

?>

6:29 pm on Nov 10, 2009 (gmt 0)

10+ Year Member



try adding..
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects

My guess is that they are doing a redirect on success, however you have not enabled that option. If you look the HTTP Response Code is probably 301 or 302.

6:49 pm on Nov 10, 2009 (gmt 0)

5+ Year Member



Thanks for the response. I do know that after the POST they reply with a 302 redirect if the login was successful, however adding the redirect option didn't solve the problem. I've tried changing the useragent too. I always get a 200 OK.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month