I have some data of type Images where I want to import in the format of xml named 'images.xml' which containing images url and information.
I want to import this file programatically using feeds API.
How can I achieve this?
for this i use following code:
$source = feeds_source($importerId);
$config = array(
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
'request_timeout' => NULL,
),
),
'parser' => array(
'plugin_key' => 'FeedsXPathParserXML',
'config' => array(
'sources' => array(
'xpathparser:0' => 'url',
),
'rawXML' => array(
'xpathparser:0' => 'xpathparser:0',
),
'context' => '//image',
'exp' => array(
'errors' => 0,
'debug' => array(
'context' => 0,
'xpathparser:0' => 0,
),
),
'allow_override' => 1,
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'expire' => '-1',
'author' => 0,
'authorize' => 1,
'mappings' => array(
0 => array(
'source' => 'xpathparser:0',
'target' => 'url',
'unique' => FALSE,
),
),
'update_existing' => '0',
'input_format' => 'full_html',
'skip_hash_check' => 0,
'bundle' => 'images',
),
),
'content_type' => 'images',
'type' => 'images',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => 0,
);
$source->importer->addConfig($config);
$featcher_config = $source->getConfigFor($source->importer->fetcher);
$featcher_config['source'] = $url;
$source->setConfigFor($source->importer->fetcher, $featcher_config);
//$source->save();
//node_save($source);
$source->startImport();
But this code show "Download of failed with code -1002" and no images are import...