Difference between revisions of "NATS4 REST API Bulk Import Adtools"
From TMM Wiki
Jump to navigationJump to searchTMMMikeSopko (talk | contribs) |
|||
Line 40: | Line 40: | ||
**'''''required''' | **'''''required''' | ||
− | *'''line_ending''' -- the string that separates the lines in the dump ('none' or '' mean that a line ending itself is the separator) | + | *'''line_ending''' -- the string that separates the lines in the dump ('none' or <nowiki>''</nowiki> mean that a line ending itself is the separator) |
**'''''type: string''''' | **'''''type: string''''' | ||
**'''''required''' | **'''''required''' | ||
Line 63: | Line 63: | ||
**'''''type: integer''''' | **'''''type: integer''''' | ||
**'''''required''' | **'''''required''' | ||
− | |||
== '''Example Request''' == | == '''Example Request''' == |
Revision as of 14:00, 3 February 2016
POST /adtools/importdump
Description
- NATS4 now supports an API action 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 API 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.
Resource URL
- http://domain/api/adtools/importdump
- Replace domain with the nats domain
- POST
Response Format
- JSON
- HTTP headers
Parameters
Paremeters must be sent with the HTTP request body.
- adtool_type -- the numeric id of the type (for FHGs, it's 2)
- type: integer
- required
- dump -- the actual adtool dump
- type: string
- required
- fields -- an array of the fields that are in the dump
- type: array
- required
- separator -- the string that separates each of the fields in the dump
- type: string
- required
- line_ending -- the string that separates the lines in the dump ('none' or '' mean that a line ending itself is the separator)
- type: string
- required
- type -- the subtype of the adtool (the type field on the adtool)
- type: integer
- required
- 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.
- type: integer
- required
- 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)
- type: string
- required
- default_group -- the adtool group that you want this to be added to
- type: integer
- required
- 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.
- type: integer
- required
Example Request
POST
http://domain/api/adtools/importdump
- Response:
"TRUE adtools sent for import"
Example Code
PHP
<?php $curl = curl_init(); $dump = 'http://www.google.com/hatz|hats|morehats'."\n"; $dump .= 'http://www.google.com/bags2|bags2|some bags'; $fields = Array('url','name','description'); $data = array( 'adtool_type_id' => 2, 'dump' => $dump, 'fields' => $fields, 'separator' => '|', 'line_ending' => '', 'type' => 1, 'enabled_on' => 1, 'publish_date' => '2010-01-28', 'default_group' => 1000, 'ignore_dupes' => 1 ); $url = 'http://domain/api/adtools/importdump'; $headers = array( 'api-key: 44b5498dbcb481a0d00b404c0169af62', 'api-username: tmm1phrvezsbu' ); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); $resp = curl_exec($curl); //dumps an associative array representation of the json var_dump(json_decode($resp, true)); // Close request to clear up some resources curl_close($curl); ?>