Difference between revisions of "NATS5 REST API Affiliate GET search"
From TMM Wiki
Jump to navigationJump to searchLine 251: | Line 251: | ||
<?php | <?php | ||
− | + | $headers = array( //set your username and API key here | |
− | + | 'api-key: 44b5498dbcb481a0d00b404c0169af62', | |
− | $headers = array( | + | 'api-username: tmm1phrvezsbu' |
− | |||
− | |||
); | ); | ||
+ | $url = 'http://yourdomain.com'; //set your NATS URL here | ||
$data = array( | $data = array( | ||
− | + | // Add API parameters here | |
); | ); | ||
Line 268: | Line 267: | ||
); | ); | ||
− | $url = ' | + | /*code below is the same for (almost) every API call */ |
+ | |||
+ | $curl = curl_init(); | ||
+ | |||
+ | $url = $url.'/api/'.$request['path']; | ||
$query = http_build_query($request['data']); | $query = http_build_query($request['data']); | ||
if($request['method'] == 'GET'){ | if($request['method'] == 'GET'){ | ||
− | $url = $url.'?'.$query; | + | //add query string parameters to the end of the url |
+ | $url = $url.'?'.$query; | ||
}else{ | }else{ | ||
+ | //send parameters as POST fields | ||
curl_setopt($curl, CURLOPT_POST, 1); | curl_setopt($curl, CURLOPT_POST, 1); | ||
− | curl_setopt($curl, CURLOPT_POSTFIELDS, $query); | + | curl_setopt($curl, CURLOPT_POSTFIELDS, $query); |
+ | |||
if($request['method'] != 'POST'){ | if($request['method'] != 'POST'){ | ||
$headers[] ='X-HTTP-Method: '.$request['method']; //send custom request method | $headers[] ='X-HTTP-Method: '.$request['method']; //send custom request method |
Revision as of 11:22, 19 April 2019
GET /affiliate/search
Description
- Search affiliates
Resource URL
- http://domain/api/affiliate/search
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
Parameters can be sent as url encoded params
- as_array
- type: boolean_digit
- optional
- count
- type: digit
- optional
- end
- optional
- orderby
- optional
- output_format
- optional
- return_payvia_info
- optional
- return_referred_info
- optional
- return_group_enabled
- type: digit
- optional
- return_payout_period_enabled
- type: digit
- optional
- return_program_enabled
- type: digit
- optional
- return_referring_info
- optional
- return_w9
- type: boolean_digit
- optional
- start
- type: digit
- optional
- widget
- type: boolean_digit
- optional
- address
- type: string
- optional
- address_compare
- type: string
- optional (default value: =)
- aim
- type: string
- optional
- aim_compare
- type: string
- optional (default value: =)
- city
- type: string
- optional
- city_compare
- type: string
- optional (default value: =)
- company
- type: string
- optional
- company_compare
- type: string
- optional (default value: =)
- country
- type: string
- optional
- country_compare
- type: string
- optional (default value: =)
- deleted
- type: boolean_digit
- optional
- email_compare
- type: string
- optional (default value: =)
- email
- type: string
- optional
- firstname_compare
- type: string
- optional (default value: =)
- firstname
- type: string
- optional
- groupid
- type: digit
- optional
- groupid_compare
- type: string
- optional (default value: =)
- group_disabled
- type: digit
- optional
- group_enabled
- type: digit
- optional
- icq_compare
- type: string
- optional (default value: =)
- icq
- type: string
- optional
- inhouse
- optional
- join_count
- optional
- join_date
- optional
- join_hits
- optional
- join_ip
- optional
- join_range
- optional
- join_submits
- optional
- lastname_compare
- type: string
- optional (default value: =)
- lastname
- type: string
- optional
- login_date
- optional
- loginid_compare
- type: string
- optional (default value: =)
- loginid
- type: digit
- optional
- login_ip
- optional
- login_range
- optional
- min_pay
- optional
- name
- type: string
- optional
- name_compare
- type: string
- optional (default value: =)
- natscode_compare
- type: string
- optional (default value: =)
- natscode
- type: string
- optional
- pay_range
- optional
- payvia_details
- optional
- payvia_type_id
- optional
- payout_period_disabled
- type: digit
- optional
- payout_period_enabled
- type: digit
- optional
- program_disabled
- type: digit
- optional
- program_enabled
- type: digit
- optional
- ratio
- optional
- raw_hits
- optional
- rebill_count
- optional
- refid
- optional
- ref
- optional
- refund_count
- optional
- sales_rep
- optional
- search_ref
- optional
- state_compare
- type: string
- optional (default value: =)
- state
- type: string
- optional
- stats_end
- optional
- stats_period
- optional
- stats_start
- optional
- status
- type: digit
- optional
- status_compare
- type: string
- optional (default value: =)
- text_search
- optional
- total_earned
- optional
- total
- optional
- type
- type: digit
- optional
- unq_hits
- optional
- url
- optional
- username_compare
- type: string
- optional (default value: =)
- username
- type: string
- optional
- zip_code_compare
- type: string
- optional (default value: =)
- zip_code
- type: string
- optional
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( // Add API parameters here ); $request = Array( 'method' => 'GET', 'path' => 'v1/affiliate/search', '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); ?>