NATS4 REST API Bulk Import Adtools

From TMM Wiki
Jump to navigationJump to search
Members Admin
The Members Admin
View Member Details
Add Member
MySQL Auth
Mod Authn DB
Multisite Access
Member Logging
Member Password Retrieval
OpenID Connect
Mod Auth OpenIDC
ID Numbers
API Best Practices
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
API Best Practices
GET /adtools/admin
GET /adtools/categories
GET /adtools/types
POST /adtools/importdump
GET /affiliate/campaigns
GET /affiliate/hitdata
GET /affiliate/payout
GET /affiliate/searchinfo
POST /affiliate/addaffiliate
POST /affiliate/invoice
PATCH /affiliate/setadminsettings
PATCH /affiliate/setcustoms
PATCH /affiliate/setdefaults
PATCH /affiliate/setinformation
PATCH /affiliate/setpayviainfo
PATCH /affiliate/setsettings
PATCH /affiliate/status
GET /member/authstring
GET /member/details
GET /member/searchinfo
GET /suggestedcanceloffers
PATCH /member/setdetails
PATCH /member/setexpiration
POST /member/addnote
POST /member/recordlogin
PUT /member/expiremanual
PATCH /member/forget
GET /option/options
GET /option/rule
PATCH /option/rule
POST /option/rule
GET /payments/getpayments
GET /payviarule
PATCH /payments/setstatus
PATCH /payviarule
GET /profitlossreport
Get /transactionpayouts
GET /report/transaction
GET /service/decodenatscode
GET /service/ping
POST /service/sendemail

POST /adtool/import


  • 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

  • https://domain/api/adtool/import
  • 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 = 'https://domain/api/adtool/import';

$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