title: trying to use libcurl to POST results in $_GET being set and not $_PUT in my server php code
body: <p>I'm using C++ on the client side and am trying to do an HTTP POST via libcurl. I've successfully done GETs with it. The problem I'm seeing though is that on my server side, the $_GET variable is being filled with my URL parameters and $_POST is empty. However, I can check file_get_contents('php://input') and it does contain the body of my POST request. </p>
  
  <p>Here's my C++ code:</p>
  
  <pre><code>CURLcode result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_WRITEFUNCTION, read_callback_func);
  result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_WRITEDATA, (void*)s-&gt;mHandle);
  result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_URL, complete_url.c_str());
  result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_POST, 1);
  result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_COPYPOSTFIELDS, body.c_str());    
  result = curl_easy_setopt(s-&gt;mHandle, CURLOPT_CONNECTTIMEOUT, 15);
  CURLMcode mresult = curl_multi_add_handle(mMultiHandle, s-&gt;mHandle);
  mresult = curl_multi_perform(mMultiHandle, &amp;mNumRunningHandles);
  </code></pre>
  
  <p>the variable "complete_url" in this case has the value "<a href="http://ip.addressofserver.com/pageinquestion.php?data=url_encoded_json_string" rel="nofollow noreferrer">http://ip.addressofserver.com/pageinquestion.php?data=url_encoded_json_string</a>"</p>
  
  <p>where the url encoded json string is an object that contains a field named "function" set to the name of the function I'm trying to execute. </p>
  
  <p>The variable "body" contains the text block that I'm trying to post to the server that the user has filled in. This is what appears when I check the value of file_get_contents('php://input'). </p>
  
  <p>When I look at what my php code on my server is getting, the $_GET field contains the key "data" mapped to the url encoded json string. $_POST is empty. Looking at my server globals, REQUEST_METHOD is set to POST and CONTENT_TYPE is application/x-www-form-urlencoded.</p>
  
  <p>Now, I can make do since I have all the information I need to insert into my DB. However it just seems "not right" to do it that way since I'd expect my libcurl POST attempt to result in my server getting a POST and not a GET. Any ideas as to what I may be doing wrong? Thanks.</p>
  
  <p>EDIT: Am I perhaps misunderstanding something fundamental? I saw the answer to this problem <a href="https://stackoverflow.com/questions/11056863/post-always-empty-get-works-ok">here</a> which implies that I should in fact see all my URL parameters in the $_GET array. $_POST is supposed to be populated with the message body (which it isn't, it's always empty) however I can access it via that php://input line of code. Is it essentially working as intended?</p>