Jump to content

php curl help please


kevinkhan

Recommended Posts

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

?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.