kevinkhan Posted March 17, 2011 Share Posted March 17, 2011 I have the following code but i can seem to log into the page can somebody tell me what is wrong please <?php error_reporting(E_ALL); $maindir = dirname(__FILE__) . DIRECTORY_SEPARATOR; include($maindir.'functions.php'); set_time_limit(0); ini_set('memory_limit','128M'); $curl_handle = curl_init(); define("SSL_CA_FILE", ".\\temp\\ssl"); define("COOKIE_FILE", "cookies.txt"); $source_file = $maindir.'login_info.txt'; // report errores error_reporting(-1); $maindir.'login_info.txt'; $fp_s = fopen($source_file, 'r'); $ch = curl_init(); //curl_followlocation set the curl to follow the site and get the final web page if the // website has redirects curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322)'); // save cookie curl_setopt($ch, CURLOPT_COOKIEJAR, $maindir.'cookie.txt'); // get cookie curl_setopt($ch, CURLOPT_COOKIEFILE, $maindir.'cookie.txt'); // not to print out the results curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $account = '*****'; $password = '*****'; if(file_exists(COOKIE_FILE)) { unlink(COOKIE_FILE); } $qryString = 'email='.urlencode($account).'&pass='.urlencode($password).'&login_type=1'; curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $qryString); curl_setopt($ch, CURLOPT_URL, 'https://secure.gumtree.ie/account/login'); $page = curl_exec($ch); echo $page; // close session curl_close($ch); ?> Quote Link to comment Share on other sites More sharing options...
btherl Posted March 17, 2011 Share Posted March 17, 2011 What happens when you try that code? Quote Link to comment Share on other sites More sharing options...
kevinkhan Posted March 18, 2011 Author Share Posted March 18, 2011 What happens when you try that code? nothing happens it just shows the login page account = 42775990 password = kevinkhan use these to test if you can please Quote Link to comment Share on other sites More sharing options...
btherl Posted March 20, 2011 Share Posted March 20, 2011 If you haven't got something equivalent, I would recommend using LiveHTTPHeaders in Firefox. It will show you exactly what is sent, so you can replicate it with curl. 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.