NATS4 REST API Admin Get Adtools
From TMM Wiki
Jump to navigationJump to searchGET adtools/admin
Description
- This resource allows adtool functions on your site.
Resource URL
- http://domain/api/adtools/admin
- Replace domain with the nats domain
- GET
Response Format
- JSON
- HTTP headers
Parameters
Paremeters can be sent as url encoded params or as part of the HTTP request body.
- typeid: The adtool type to get adtools for (see the (GET adtools/types resource)
- type: string
- required
- natscode: Input your NATS code here. This specifies the loginid, campaignid, programid, siteid, and tourid used for the adtool. This is used when deciding what adtools are available, as well as what link code to use. You can build your own NATS code using an unencoded structure - please refer to this article about Unencoded Link Codes.
- type: string
- optional
- siteid: This gives you the option to override the siteid that already exists in the NATS code. This parameter is optional; if you do not want to override your siteid, input 0 to disable it.
- type: string
- optional
- options: A serialized array of parameters. See nats_display_adtools for the available parameters (you can use category, typeid, start, count, order, searchinline, and the search fields)
- type: PHP Serialized Array
- optional
Example Request
GET
http://domain/api/adtools/admin
- Response:
[ { "adtoolid": "216", "name": "asdf", "url": "asdf", "date_added": null, "published_date": "1417496400", "trackrl": "http:\/\/domain\/gallery\/MC44LjEuMy4wLjIxNi4wLjAuMA", "natscode": "MS44LjEuMy4wLjIxNi4wLjAuMA", "extra": { "identid": "4", "siteid": "0", "networkid": "0", "type": "1", "items": "0", "description": "", "thumbnail": "", "thumb_ext": "", "deleted": "0", "model": "", "ids": { "loginid": "1", "programid": "8", "siteid": "1", "siteids": [ "1", "2", "3", "4" ] }, "var_divide": "?" } } ]
Example Code
PHP
<?php $curl = curl_init(); $options = array( 'searchinline' => 1, 'search_type' => '5:1' ); $data = array( 'natscode' => 'tmm1phrvezsbu.8.1.3.0.0.0.0.0', 'typeid' => '1', 'siteid' => 1, 'options' => serialize($options) ); $data_string = http_build_query($data); $url = 'http://domain/api/adtools/admin?'.$data_string; $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); $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); ?>