API Bulk Import Adtools
NATS4 now supports an API function that allows you to import bulk adtools. This lets you insert your custom adtools into the NATS tools through an automated process by running a cron that calls the bulk import API for your adtools import. This function sends all the standard information for the bulk importer (the dump, what the separator and fields are, etc.) so NATS can process the imported adtools as normal for the bulk importer.
Function Arguments
The API function to import bulk adtools is called import_adtools_dump. The arguments for this function are as follows:
- adtool_type -- the numeric id of the type (for FHGs, it's 2)
- dump -- the actual adtool dump
- fields -- an array of the fields that are in the dump
- separator -- the string that separates each of the fields in the dump
- line_ending -- the string that separates the lines in the dump ('none' or mean that a line ending itself is the separator)
- type -- the subtype of the adtool (the type field on the adtool)
- enabled_on -- the siteid it should be enabled on or a comma separated list of siteids it should be enabled on. -1 means no sites. 0 means all sites.
- publish_date -- the date you want it published. Can be anything you would put in to the field in the adtools admin the recommended format is YYYY-mm-dd (eg. 2010-01-31)
- default_group -- the adtool group that you want this to be added to
- ignore_dupes -- if set, instead of returning an error if a row has a duplicate to a unique field for an existing adtool, we'll instead just ignore the row.
If the importing worked correctly, the response will start with TRUE. If it didn't, it will start with FALSE, followed by the error.
Our NATS4 API article contains example code for using API functions, which you can build off of when implementing our bulk import adtools API. The following is an example of some code you can use to call the API function:
$dump = 'http://www.google.com/hatz|hats|morehats'."\n"; $dump .= 'http://www.google.com/bags2|bags2|some bags'; $fields = Array('url','name','description'); // Call the SOAP method $values = array( 'adtool_type' => 2, 'dump' => $dump, 'fields' => $fields, 'separator' => '|', 'line_ending' => '', 'type' => 1, 'enabled_on' => 1, 'publish_date' => '2010-01-28', 'default_group' => 1000, 'ignore_dupes' => 1 ); $result = $client->call('import_adtools_dump', $values, 'natsapiadmin_wsdl');