homepage Welcome to WebmasterWorld Guest from 54.211.230.186
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Trying to automate login
automate login
webworxs

5+ Year Member



 
Msg#: 4022369 posted 1:58 pm on Nov 10, 2009 (gmt 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:


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

?>

 

JohnCanyon

10+ Year Member



 
Msg#: 4022369 posted 6:29 pm on Nov 10, 2009 (gmt 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.

webworxs

5+ Year Member



 
Msg#: 4022369 posted 6:49 pm on Nov 10, 2009 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved