I try to login on a site using curl lib. After I login I have to go to a diferent url and retrive the content of that page.
This is my aproce:
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$url = 'http://domain';
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"{$url}/login.php");
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_COOKIEJAR, '-');
curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=username&password=password");
if (curl_errno($ch)) echo curl_errno($ch);
else curl_close ($ch);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL,"{$url}/page2.php?param1=value1¶m2=value2");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0);
$tmp = curl_exec ($ch);
if (curl_errno($ch)) echo curl_errno($ch);
else curl_close ($ch);
echo $tmp;
If anyone could point me to the right direction please do.
Thanks in advanced!!!