Programmatically import a feed
Your code seems to be OK. I use some similar code in one of my projects (this a csv importer, similar concept):

function custom_function($importer_id, $csvfile_path) {
  // Load the Feeds Source object.
  $source = feeds_source($importer_id);
  // Load the source fetcher config.
  $fetcher_config = $source-&gt;getConfigFor($source-&gt;importer-&gt;fetcher);
  $fetcher_config['source'] = $csvfile_path;
  $source-&gt;setConfigFor($source-&gt;importer-&gt;fetcher, $fetcher_config);
  $source-&gt;save();
  $source-&gt;startImport();
}


Make sure that you are using the foreground configuration, this way the batch process could be be executed "inside" drupal with showing the progress bar. Or you can force it:

// Tweak the importer configuration, to enable "Process in the background".
$config = array(
  'process_in_background' =&gt; TRUE,
);
$source-&gt;importer-&gt;addConfig($config);

// Execute the import.


Another approach could be to schedule it

// Schedule the import, and make sure importer is scheduled, too.
$source-&gt;schedule();
$source-&gt;importer-&gt;schedule();


This is a good article about feeds importer