I'm trying to export webform results through hook_cron() in drupal 7.
$webform_node = node_load($wid);
if (is_object($webform_node)){
module_load_include('inc', 'webform', 'includes/webform.report');
$export_info = webform_results_export($webform_node);
webform_results_download($webform_node, $export_info );
}
The problem is on the line webform_results_download(). It creates an error in XDebug saying:
"Fatal error: Call to a member function set_headers() on a non-object"
When trying to debug the code, I remark the error was caused by
$export_info['exporter']->set_headers($export_name);
This variable $export_info['exporter'] is not existing. How can i set it manually, or what is the best alternative if i want to just get webform results by cron. Need help. Thanks.