title: PHP4: Send XML over HTTPS/POST via cURL?
body: <p>I wrote a class/function to send xml over https via PHP4/cURL, just wondering if this is the correct approach, or if there's a better one.</p>
  
  <p>Note that PHP5 is not an option at present.</p>
  
  <pre><code>/**
   * Send XML via http(s) post
   *
   * curl --header "Content-Type: text/xml" --data "&lt;?xml version="1.0"?&gt;...." http://www.foo.com/
   *
   */
  function sendXmlOverPost($url, $xml) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
  
    // For xml, change the content-type.
    curl_setopt ($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
  
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ask for results to be returned
    if(CurlHelper::checkHttpsURL($url)) { 
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    }
  
    // Send to remote and return data to caller.
    $result = curl_exec($ch);
    curl_close($ch);
    return $result;
  }
  </code></pre>
  
  <p>cheers!</p>