NATS4 REST API Bulk Import Adtools

From TMMwiki
Jump to: navigation, search
WSDL Cache
Add Affiliate
Add Member Note
Admin Get Adtools
Adtool Categories
Adtool Types
Affiliate Get Campaigns
Bulk Import Adtools
Decode Natscode
Expire Manual Member
Get Affiliate Campaigns
Get Affiliate Hit Data
Get Affiliate Loginids
Get Affiliate Nats Codes
Get Affiliate Payout
Get Affiliate Program Campaign List
Get Member Details
Get Member Instant Upgrade String
Get Member Package Upgrade String
Get Member Token Rebuy String
Get Member Upsell String
Get Payment Data
Get Payvia Rule
Get Profit Loss Report
Record Member Login
Search Affiliate Info
Search Member Info
Send Email API Function
Set Affiliate Admin Settings
Set Affiliate Customs
Set Affiliate Defaults
Set Affiliate Information
Set Affiliate Settings
Set Member Details
Set Payment Status
Set Payvia Rule
API Overview
GET /adtools/types
GET /adtools/categories
GET /adtools/admin
POST /adtools/importdump
GET /affiliate/hitdata
GET /affiliate/campaigns
GET /affiliate/payout
GET /affiliate/searchinfo
POST /affiliate/addaffiliate
PATCH /affiliate/setcustoms
PATCH /affiliate/setinformation
PATCH /affiliate/setadminsettings
PATCH /affiliate/setpayviainfo
PATCH /affiliate/setdefaults
PATCH /affiliate/setsettings
GET /decodenatscode
GET /member/upsellstring
GET /member/tokenrebuystring
GET /member/instantupgradestring
GET /member/packageupgradestring
GET /member/details
GET /member/cancelstring
GET /member/signupplusstring
GET /member/searchinfo
POST /member/addnote
POST /member/recordlogin
PUT /member/expiremanual
PATCH /member/setdetails
PATCH /member/setexpiration
GET /option/getrule
POST /option/addrule
PUT /option/edittext
PATCH /option/editrule
GET /payments/getpayments
PATCH /payments/setstatus
GET /payviarule
PATCH /payviarule
GET /ping
GET /profitlossreport
POST /sendemail
GET /suggestedcanceloffers

POST /adtools/importdump


  • 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

Request Method

  • POST

Response Format

  • JSON


  • HTTP headers


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



  • Response:
"TRUE adtools sent for import"

Example Code


$curl = curl_init();

$dump = '|hats|morehats'."\n";
$dump .= '|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