title: PHP curl maximum execution time using hhvm
body: <p>I am trying to download all the data from an api, so I am curling into it and saving the results a json file. But the execution stops and the results are truncated and never finishes.</p>
  
  <p>How can this be remedied. Maybe the maximum execution time in the server of api cannot serve so long so it stops. I think there are more than 10000 results.</p>
  
  <p>Is there a way to download the first 1000, 2nd 1000 results etc. and by the way, the api uses <a href="https://github.com/balderdashy/sails" rel="nofollow">sails.js</a> for their api, </p>
  
  <p>Here is my code :</p>
  
  <pre><code>&lt;?php
  $url = 'http://api.example.com/model';    
  $data = array (
    'app_id' =&gt; '234567890976',
    'limit' =&gt; 100000
  );
  
  
  $fields_string = '';
  foreach($data as $key=&gt;$value) { $fields_string .= $key.'='.urlencode($value).'&amp;'; }
  $fields_string = rtrim($fields_string,'&amp;');
  
  
  $url = $url.'?'.$fields_string;
  
  $ch = curl_init();
  
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_TIMEOUT, '300000000');
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  
  $response = curl_exec($ch);
  print($response);
  $file = fopen("results.json", 'w+'); // Create a new file, or overwrite the existing one.
  fwrite($file, $response);
  fclose($file);
  
  curl_close($ch);
  </code></pre>