You are here

function rec_transfer_download_results in Recommender API 6.3

Same name and namespace in other branches
  1. 7.4 rec_transfer/rec_transfer.module \rec_transfer_download_results()
  2. 7.5 rec_transfer/rec_transfer.module \rec_transfer_download_results()
1 call to rec_transfer_download_results()
rec_transfer_import_results in rec_transfer/rec_transfer.module

File

rec_transfer/rec_transfer.module, line 261
This is the module file for Recommender Data Transfer

Code

function rec_transfer_download_results($download_file, $save_file) {
  $fp = fopen($save_file, 'w');
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_USERAGENT, "Drupal (Recommender)");
  curl_setopt($ch, CURLOPT_ENCODING, "gzip");
  curl_setopt($ch, CURLOPT_URL, variable_get('rec_transfer_endpoint', '') . "/download/{$download_file}");
  curl_setopt($ch, CURLOPT_FILE, $fp);
  $response = curl_exec($ch);
  $download_success = $response && curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200;
  curl_close($ch);
  fclose($fp);
  return $download_success;
}