Welcome to WebmasterWorld Guest from

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)

New User

5+ Year Member

joined:Nov 10, 2009
posts: 3
votes: 0

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:



$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);


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

Junior Member

10+ Year Member

joined:Sept 10, 2004
votes: 0

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)

New User

5+ Year Member

joined:Nov 10, 2009
posts: 3
votes: 0

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.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members