Difference between revisions of "NATS5 REST API Affiliate POST add"
From TMM Wiki
Jump to navigationJump to searchLine 38: | Line 38: | ||
** required | ** required | ||
* '''tel''' | * '''tel''' | ||
− | |||
* '''icq''' | * '''icq''' | ||
− | |||
* '''aim''' | * '''aim''' | ||
− | |||
* '''msn''' | * '''msn''' | ||
− | |||
* '''address1''' | * '''address1''' | ||
** required | ** required | ||
* '''address2''' | * '''address2''' | ||
− | |||
* '''city''' | * '''city''' | ||
** required | ** required | ||
Line 58: | Line 53: | ||
** required | ** required | ||
* '''tax_id_or_ssn''' | * '''tax_id_or_ssn''' | ||
− | |||
* '''ref''' | * '''ref''' | ||
− | |||
* '''minimum_payout''' | * '''minimum_payout''' | ||
** required | ** required |
Latest revision as of 11:41, 5 October 2021
POST /affiliate/add
Note: This is an autogenerated wiki page for the NATS5 API. There may be additional descriptions or examples available on the NATS 4 API wiki for this API.
Description
- Add affiliates
Resource URL
- http://domain/api/affiliate/add
- Replace domain with the nats domain
- POST
Response Format
- JSON
- HTTP headers
Parameters
Parameters can be sent as url encoded params
- username
- required
- password
- required
- firstname
- required
- lastname
- required
- email
- required
- company
- required
- url
- required
- tel
- icq
- aim
- msn
- address1
- required
- address2
- city
- required
- state
- required
- country
- required
- zip_code
- required
- tax_id_or_ssn
- ref
- minimum_payout
- required
Example Request
Method: POST
URL: http://domain/api/affiliate/add
Form Data:
- username: affiliateTest
- password: test
- firstname: Test
- lastname: Affiliate
- email: itai.levi@toomuchmedia.com
- company: TMM
- url: toomuchmedia.com
- tel: 111-111-1111
- icq: 111111111
- aim: testaffiliate
- msn: testaffiliate
- address1: 1 affiliate st
- address2:
- city: City
- state: State
- country: US
- zip_code: 11111
- tax_id_or_ssn: 111111111
- ref: asdf
- minimum_payout: 1
Response:
{ "success": true, "result": true, "loginid": "3" }
Example Code
PHP
<?php $headers = array( //set your username and API key here 'api-key: 44b5498dbcb481a0d00b404c0169af62', 'api-username: tmm1phrvezsbu' ); $url = 'http://yourdomain.com'; //set your NATS URL here $data = Array( 'username' => 'affiliateTest', 'password' => 'test', 'firstname' => 'Test', 'lastname' => 'Affiliate', 'email' => 'itai.levi@toomuchmedia.com', 'company' => 'TMM', 'url' => 'toomuchmedia.com', 'tel' => '111-111-1111', 'icq' => '111111111', 'aim' => 'testaffiliate', 'msn' => 'testaffiliate', 'address1' => '1 affiliate st', 'address2' => '', 'city' => 'City', 'state' => 'State', 'country' => 'US', 'zip_code' => '11111', 'tax_id_or_ssn' => '111111111', 'ref' => 'asdf', 'minimum_payout' => 1, ); $request = Array( 'method' => 'POST', 'path' => 'v1/affiliate/add', 'data' => $data ); /*code below is the same for (almost) every API call */ $curl = curl_init(); $url = $url.'/api/'.$request['path']; $query = http_build_query($request['data']); if($request['method'] == 'GET'){ //add query string parameters to the end of the url $url = $url.'?'.$query; }else{ //send parameters as POST fields curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $query); if($request['method'] != 'POST'){ $headers[] ='X-HTTP-Method: '.$request['method']; //send custom request method } } curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $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); ?>