title: Converting wp_remote_post() to cURL
body: <p>I have this WordPress code using <code>wp_remote_post()</code> to make an API call to LinkedIn. </p>
  
  <pre><code>    $args = array(
                  'headers' =&gt; array('Content-Type' =&gt; 'text/xml'),
                  'body' =&gt; "&lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&gt;&lt;company&gt;&lt;id&gt;{$nCompanyID}&lt;/id&gt;&lt;/company&gt;"
              ); 
      $access_token = $datapass-&gt;access_token_get();                    
      $params = array('oauth2_access_token' =&gt; $access_token); 
      $resource = "https://api.linkedin.com/v1/people/~/following/companies?" . http_build_query($params);        
      $response = wp_remote_post( $resource, $args); 
      $code = $response['response']['code'];
      $body = wp_remote_retrieve_body($response);
      $RV = ($code == '201');
      return $RV;  
  </code></pre>
  
  <p>It works.  Now, I need to convert it to php cURL.
  I have tried various examples of php cURL posting XML that I found online, but no luck.
  Here's the latest attempt.</p>
  
  <pre><code>$access_token = "long_string_of_characters";
  $nCompanyID = 2495437;
  $xml = "&lt;?xml version='1.0' encoding='UTF-8' standalone='yes'?&gt;&lt;company&gt;&lt;id&gt;{$nCompanyID}&lt;/id&gt;&lt;/company&gt;";
  $url = 'https://api.linkedin.com/v1/people/~/following/companies?oauth2_access_token='.$access_token;
  
  $headers = array(
      "Content-type: text/xml",
      "Content-length: " . strlen($xml)
  );
  
  $ch = curl_init(); 
  curl_setopt($ch, CURLOPT_URL,$url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, array('body' =&gt; $xml));
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  $data = curl_exec($ch); 
  </code></pre>
  
  <p><code>$data</code> comes back with a 400 error and message saying 'Unexpected element: CDATA'.  If I remove the array from <code>CURLOPT_POSTFIELDS</code> and use just <code>$xml</code>, $data comes back as an empty string.  </p>
  
  <p>Any help will be appreciated.</p>