cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

curl weird behavior

From: Frank <frank_at_optimarc.com>
Date: Tue, 21 Sep 2004 16:42:52 +1000

Hi guys, I use curl and php to login to a https website and download a
particular file everyday.

I found that the file is been downloaded every 2 days instead of
everyday. (there is not error in the crontab entry)

I found that the session cookie expires every 36 hours. So
- today, I access the site it sets the cookie file but download no file
- tomorrow, finds the cookie and download the file
- the next day, the cookie is expired, reset the cookie but do not
download any file

any ideas what am I doing wrong?

Here is my code
           
          $url = "https://...";
        $postFields = "username=user&password=pass";
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$url);
        curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
        curl_setopt($ch,CURLOPT_COOKIEFILE,"cookie.txt");
        curl_setopt($ch,CURLOPT_POST,TRUE);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$postFields);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,TRUE);
                
         ob_start();
                curl_exec($ch);
           ob_end_clean(); // stop preventing output

                
         $url = "https:// .. file.txt"
           curl_setopt($ch,CURLOPT_URL,$url); // same curl handle
           curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
             ob_start();
                 $response = curl_exec($ch);
                 ob_end_clean();
                        
        cheers

frank
Received on 2004-09-21