title: Invalid json response on remote server
body: <p>I have a very strange problem which I have been trying to figure out for 2 days, I have the below code to fetch information from a site for flight information, it works perfectly on my localhost and returns me "<code>{thedata:what_I_Need}</code>" but when I upload the script on my server it returns an "<code>{invalid:true}</code>" error from the site. </p>
  
  <p>I tried it on 4 different droplets/vps, each in a different country IP with the same configuration (same curl-php-apache version and modules) as my local computer ( using ubuntu 14.4 with php5) but it still has the same issue. Here is the code which works perfectly on localhost:</p>
  
  <pre><code>   $url = 'http://site.url.com';
      $post = array(
          'LanguageID' =&gt; 2,
          'Trips' =&gt; array(array(
                      'Origin' =&gt; "JFK",
                      'Destination' =&gt; "TEX",
                      'Departure' =&gt; "2015-12-24T00:00:00",
                      )),
          'Return' =&gt; "2015-12-28T00:00:00",
          'Carriers' =&gt; null
          'Adults' =&gt; 1,
          'Children' =&gt; 0
      );  
      $data_string = json_encode($post); 
  
      $ch = curl_init($url);                                
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
      curl_setopt($ch,CURLOPT_HEADER, 1); 
      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1");
      curl_setopt($ch, CURLOPT_REFERER, "http://www.site.url.com");
      curl_setopt($ch, CURLOPT_TIMEOUT, 20);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
          'Content-Type: application/json',       
          'X-Requested-With: XMLHttpRequest',                                                                                
          'Content-Length: ' . strlen($data_string))                                                                       
      );
      curl_setopt($ch, CURLOPT_COOKIE, $cookie);
      $output=curl_exec($ch);
      curl_close($ch);
  </code></pre>
  
  <p>I followed <a href="http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl" rel="nofollow">this</a> article as well but I still have same issue on the remote site even if I replace <code>CURLOPT_POST</code> with</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);    
  </code></pre>