Hello,
I'm trying to automate downloading from turbobit.net through php, i login successfully and get all the cookies. then when i try to intiate another connection to download a file i get these headers back

HTTP/1.1 200 OK Date: Thu, 26 Jul 2012 17:44:02 GMT Content-Type: text / html; charset = UTF-8 Transfer-Encoding: chunked Connection: keep-alive Server: Apache/2.2.17 (FreeBSD ) X-Powered-By: PHP/5.3.6 Set-Cookie: kohanasession = 6cadbdd3a672521dc2d5300ffcd171% 7E; expires = Wed, 25-Jul-2012 17:44:02 GMT; path = / Set-Cookie: kohanasession = 59356c3ccc6cc6fffd76e7; expires = Thu, 26-Jul-2012 20:44:02 GMT; path = / Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check = 0, pre-check = 0 Pragma: no-cache Set-Cookie: kohanasession = 7c638f49b6a12c776d472f21ca3b7% 7E594a3ab17bce356c3ccc6cc6fffd76e7; expires = Thu, 26-Jul-2012 20:44:02 GMT; path = / Set-Cookie: sid = 8116a48a58d5f88cc6cd9722309bc1ce99% 7E; expires = Wed, 25-Jul-2012 17:44:02 GMT; path = / Set-Cookie: compid = 1be9124912615302d539ace729f2ec% 7E; expires = Wed, 25-Jul-2012 17:44:02 GMT; path = / Set-Cookie: compid = f06a60e996****e6cc619bbfb9fc40% 7E8222534783D7BED9D0A8EC1FD5A; expires = Fri, 26-Jul-2013 17:44:02 GMT; path = / Set-Cookie: user_isloggedin = deleted; expires = Wed, 27-Jul-2011 17:44: 01 GMT; path = / Set-Cookie: user_lang = ru; path = / Set-Cookie: refuid = 10a524e67c7a7b7b07d571eda4f61eacbddddf3e% 7EE2183B36E74D4E97F5D8AB5D280571BE; expires = Fri, 26-Jul-2013 17:44:02 GMT; path = /

if you noticed
Set-Cookie: user_isloggedin = deleted; expires = Wed, 27-Jul-2011 17:44: 01 GMT

while when i login its set to 1, but when i try to get the download link its rejecting, anyone can tell me what are cause of this. and did anyone do something like before

thanks

function DMcURL($url, $cookie = false, $header = false, $body = false, $ref = false, $post = false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

if($header != false) curl_setopt($ch, CURLOPT_HEADER, $header);
if($body != false) curl_setopt($ch, CURLOPT_NOBODY, $body);
if($ref != false) curl_setopt($ch, CURLOPT_REFERER, $ref);

if($post != false) 
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}

if ($cookie != false) curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies/'.$cookie);

$content = curl_exec($ch);
return $content;
}


function DMLogin($url, $post = false, $ref = false, $cookie = false)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

if($ref != false) curl_setopt($ch, CURLOPT_REFERER, $ref);

if($post != false) 
{
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}

if ($cookie != false) curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies/'.$cookie);


if ($content = curl_exec($ch))  return $content;
else return false;
}


//this one works fine, i get the correct cookies
$postfields = 'user[login]=xxx&user[pass]=xxx&user[memory]=on&user[submit]=Login';
$process = DMLogin('http://turbobit.net/user/login', $postfields, false, 'turbobit1');


$e = DMcURL($link, 'turbobit1', 1, 1, $link);
echo $e;
//here is where i get the strange headers
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.