title: PHP curl doesn't return all the response
body: <p>I am trying to use an API in php which (as usual) returns a large json response with the requested data.</p>
  
  <h3>It works like this:</h3>
  
  <p>1) I have to make a post request with the data i want (in a certain format which is not important here) and then,</p>
  
  <p>2) Visit another url where with a get parameter which i get from the response of step one to get the actual data.</p>
  
  <p>The problem is that i tryed both curl() and get_file_contents() to obtain the json data but it seems that i do not get the whole json. I visit the url from my browser and get the json manually and compare and see if the two match. </p>
  
  <p>What can possibly be wrong?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$tp = new TravelPayoutApi();
  $req = $tp-&gt;request_one_way('en', 'Y', 1,0,0, 'BER', 'PAR', '2017-10-22');
  //$req = $tp-&gt;requestRoundTrip('en', 'Y', 1,0,0, 'BER', 'PAR', '2017-10-22','2017-10-25');
  echo "req =" . $req;
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, "http://api.travelpayouts.com/v1/flight_search"); // $apiURL = "http://api.travelpayouts.com/v1/flight_search";
  
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));                                    
  
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  
  // $response = array();
  // echo $response;
  $response = curl_exec($ch);
  curl_close($ch);
  $response = json_decode($response, true);
  $search_id = $response['search_id'];
  echo $search_id;
  </code></pre>
  
  <h3>This was the part that gets the parameter i need to collect the data</h3>
  
  <h3>Here are my efforts to obtain and echo them:</h3>
  
  <pre><code>$results = file_get_contents("http://api.travelpayouts.com/v1/flight_search_results?uuid=" . $search_id);
  var_dump($results); // to see if this is really json
  // $ch1 = curl_init();
  // $resultsURL = "http://api.travelpayouts.com/v1/flight_search_results?uuid=" . $search_id;
  // echo "This is the results URL:" . $resultsURL;
  // curl_setopt($ch1, CURLOPT_URL, $resultsURL);
  // curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);
  
  // $results = curl_exec($ch1);
  // $results = json_encode($results);
  // curl_close($ch1);
  </code></pre>
  
  <p>The commented lines at the and are different scripts i have tried. Take a look at them too.</p>
  
  <h2>EDIT:</h2>
  
  <p>Ok, i tried the original curl command the API <strong>(curl -v -H 'Accept-Encoding:gzip,deflate,sdch' htttp://api.travelpayouts.com/v1/flight_search_results?uuid=my_id_here --compressed)</strong>, and it works like a charm. But it seems that i can not get it to work with php curl. I always get my results truncated. What can i do about this? </p>
  
  <p>My current code to get the results is:</p>
  
  <pre><code>$ch1 = curl_init();
  
  curl_setopt($ch1, CURLOPT_URL, $resultsURL);
  curl_setopt($ch1, CURLOPT_HTTPHEADER, array('Accept-Encoding: gzip,deflate,sdch')); 
  curl_setopt($ch1, CURLOPT_ENCODING, 'gzip,deflate,sdch');
  // curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT, 0);
  //curl_setopt($ch1, CURLOPT_TIMEOUT, 15); // number of seconds to allow curl to execute
  
  $results = curl_exec($ch1);
  echo($results);
  curl_close($ch1);
  </code></pre>