title: Login to Remote Site and Exporting XML with PHP cURL
body: <p>I'm trying to log into <a href="https://ipslight.upu.org" rel="nofollow">IPS Light</a> and exporting a XML file. The url of the export page is unique and cannot be directly referenced in the script; Meaning that I will be required to click the necessary links on the homepage that will redirect me to the XML Export page.</p>
  
  <pre><code>require_once( dirname(__FILE__) . "/configuration.php" );
  
  $username = "username";
  $password = "password";
  
  $dir = site_path."/ctemp";
  $path = site_path."/ctemp/test";
  
  $url="https://ipslight.upu.org/"; 
  $postinfo = "email=".$username."&amp;password=".$password;
  
  $cookie_file_path = $path."/cookie.txt";
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_HEADER, false);
  curl_setopt($ch, CURLOPT_NOBODY, false);
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  
  curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
  curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
  curl_setopt($ch, CURLOPT_USERAGENT,
      "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
  curl_exec($ch);
  
  curl_setopt($ch, CURLOPT_URL, "https://ipslight.upu.org/IPSLight.dll");
  $html = curl_exec($ch);
  curl_close($ch);
  </code></pre>