title: Downloading from member area of a site programmatically with cURL
body: <p>This is the sort of link I want to download with:</p>
  
  <pre><code>http://username:password@example.com/dl/file.zip
  </code></pre>
  
  <p>Edit: stackoverflow seems to go weird with colons, its username-colon-password.</p>
  
  <p>Now, if I log out of the website and use the URL pattern above, it successfully authenticates and I can successfully download the file.</p>
  
  <p>I have this cURL script:</p>
  
  <pre><code>&lt;?php
  echo "Attempting to download...&lt;br /&gt;";
  $out = fopen("zip.zip", 'wb');
  if ($out == FALSE){
   die('File could not be opened, exiting.');
  }
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_FILE, $out);
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_URL, $file);
  
  curl_exec($ch);   
  curl_close($ch);
  fclose($out);
  ?&gt;
  </code></pre>
  
  <p>And for some reason, it just downloads a 0KB file. I'm pretty sure the coding is correct, but then it can't be if it's not working.</p>
  
  <p>Any help? Thanks.</p>