PHP log into remote site and download csv
<p>I need to create a php script that logs into remote site then downloads a csv file on that site.  I've searched all over and haven't found anything that does what I need. Currently I only have the following code which allows me to login to a remote site.</p>

<pre><code>&lt;?php
$username=""; 
$password=""; 
$url=''; 
$cookie=""; 
$postdata = 'email='.$username.'&amp;pass='.$password; 

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;       rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); 
curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); 
curl_setopt($ch, CURLOPT_POST, true); 
$result = curl_exec($ch); 
echo $result;  
curl_close($ch);
</code></pre>

<p>?></p>
