title: POST cURL request to REST API sending
body: <p>I've been trying for a while now to call a REST API, but still with no luck.</p>
  
  <p>I've tested the connection, propreties and credentials with <a href="http://www.wiztools.org/" rel="nofollow">WizTools</a>, so I'm 100% all the data is correct and working. Only when I try to connect to the API using custom PHP, things go wrong.  </p>
  
  <p>I use <a href="http://www.fiddler2.com/fiddler2/version.asp" rel="nofollow">Fiddler</a> for debugging and all I see is a request to the local path of the file with the code. For some reason, the snippet isn't calling the REST endpoint... I would like to know how does it come and what do I do wrong...  </p>
  
  <p>The code is hosted local (<code>dev.testing.com</code>).<br>
  At first sight, I would think the code below is correct, so I'm wondering why I get a <code>GET http://dev.testing.com/talent.php HTTP/1.1</code> result in Fiddler, while I should get a <code>POST https://api.some_url.com/package/REST/service/criteria?api_key=my_Key HTTP/1.1</code>..</p>
  
  <pre><code>&lt;?php
         // Set all the data
         $service_url = "https://api.some_url.com/package/REST/service/criteria?api_key=my_Key";
         $service_user = 'iiii_My_Username:text:FO';
         $service_pass = 'password';
  
         // Initialize the cURL
         $ch = curl_init($service_url);
  
         // Set service authentication
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
         curl_setopt($ch, CURLOPT_USERPWD, "{$service_user}:{$service_pass}");
  
         // Composing the HTTP headers     
         $body = "&lt;searchCriteriaSorting&gt;&lt;/searchCriteriaSorting&gt;";
  
         $headers = array();
         $headers[] = 'Accept: application/xml';
         $headers[] = 'Content-Type: application/xml; charset=UTF-8';
  
         // Set the cURL options
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
         curl_setopt($ch, CURLOPT_POST, TRUE);
         curl_setopt($ch, CURLOPT_VERBOSE, 1);
         curl_setopt($ch, CURLOPT_HEADER, TRUE);
         curl_setopt($ch, CURLINFO_HEADER_OUT, true);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
         curl_setopt($ch, CURLOPT_ENCODING, '');
         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
  
         //WARNING: this would prevent curl from detecting a 'man in the middle' attack
         curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
         curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
  
         // Execute the cURL
         $data = curl_exec($ch);
  
         // Print the result
         echo $data;
  ?&gt;
  </code></pre>